Skip to content

Commit 10770ae

Browse files
Replace defaultProps with JS default parameters and remove unused dependencies
- Migrate 21 function components from deprecated defaultProps to JS default parameters (React 18.3+ deprecation) - Remove unused dependencies: @react-native-community/hooks, react-native-web, react-native-fast-image - Move build-only deps to devDependencies: @babel/plugin-proposal- export-namespace-from, patch-package, react-native-gesture-handler, @bigbinary/neeto-commons-frontend (needed by eslint plugin) - Remove AnimatedImage component and its storybook story - Fix peerDependencies to use >= ranges instead of exact versions
1 parent 87eb9a3 commit 10770ae

26 files changed

Lines changed: 114 additions & 551 deletions

package.json

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,43 +40,38 @@
4040
},
4141
"peerDependencies": {
4242
"react-native-device-info": "^10.3.0",
43-
"react-native-reanimated": "3.6.0",
44-
"react-native-safe-area-context": "^3.3.2",
43+
"react-native-reanimated": ">=3.6.0",
44+
"react-native-safe-area-context": ">=3.3.2",
4545
"react-native-svg": "*",
46-
"react-native-webview": "11.14.4"
46+
"react-native-webview": ">=11.14.4"
4747
},
4848
"dependencies": {
49-
"@babel/plugin-proposal-export-namespace-from": "^7.18.9",
50-
"@bigbinary/neeto-commons-frontend": "^2.0.129",
5149
"@bigbinary/neeto-icons-rn": "^1.0.7",
52-
"@react-native-community/hooks": "^2.8.1",
5350
"@shopify/flash-list": "^1.2.0",
5451
"@styled-system/prop-types": "^5.1.5",
5552
"dayjs": "^1.11.4",
5653
"node-html-parser": "^6.1.5",
57-
"patch-package": "^8.0.0",
5854
"react-content-loader": "^6.2.0",
5955
"react-native-calendars": "^1.1285.0",
6056
"react-native-controlled-mentions": "^2.2.5",
61-
"react-native-fast-image": "^8.6.3",
62-
"react-native-gesture-handler": "^2.4.0",
6357
"react-native-modal": "^13.0.0",
58+
"react-native-safe-area-context": "^3.3.2",
6459
"react-native-pell-rich-editor": "^1.9.0",
6560
"react-native-popover-view": "^5.1.7",
66-
"react-native-safe-area-context": "^3.3.2",
6761
"react-native-size-matters": "^0.4.0",
6862
"react-native-snap-carousel": "4.0.0-beta.6",
6963
"react-native-toast-message": "^2.1.5",
70-
"react-native-web": "^0.19.9",
7164
"styled-components": "^5.3.3",
7265
"styled-system": "^5.1.5"
7366
},
7467
"devDependencies": {
7568
"@babel/cli": "^7.16.0",
7669
"@babel/core": "^7.12.9",
70+
"@babel/plugin-proposal-export-namespace-from": "^7.18.9",
7771
"@babel/eslint-parser": "^7.19.1",
7872
"@babel/runtime": "^7.12.5",
7973
"@bigbinary/eslint-plugin-neeto": "^1.0.15",
74+
"@bigbinary/neeto-commons-frontend": "^2.0.129",
8075
"@bigbinary/neeto-cist": "^1.0.6",
8176
"@react-native-async-storage/async-storage": "^1.15.11",
8277
"@react-native-community/datetimepicker": "^3.5.2",
@@ -128,12 +123,14 @@
128123
"jest": "^26.6.3",
129124
"lint-staged": "^12.0.3",
130125
"metro-react-native-babel-preset": "^0.66.2",
126+
"patch-package": "^8.0.0",
131127
"prettier": "^2.3.1",
132128
"ramda": "^0.29.1",
133129
"react": "18.1.0",
134130
"react-dom": "^18.2.0",
135131
"react-native": "0.70.6",
136132
"react-native-device-info": "^10.3.0",
133+
"react-native-gesture-handler": "^2.4.0",
137134
"react-native-pager-view": "^5.4.25",
138135
"react-native-reanimated": "3.6.0",
139136
"react-native-screens": "^3.15.0",

src/components/AnimatedImage.jsx

Lines changed: 0 additions & 142 deletions
This file was deleted.

src/components/Avatar.jsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ export const Avatar = ({
4646
bgColor = "background.lightBlue100",
4747
fontColor = "font.darkBlue100",
4848
imageUrl,
49+
alignItems = "center",
50+
justifyContent = "center",
4951
...rest
5052
}) => {
5153
const opacity = useSharedValue(0);
@@ -82,9 +84,11 @@ export const Avatar = ({
8284

8385
return (
8486
<Container
87+
alignItems={alignItems}
8588
bg={bgColor}
8689
borderRadius={avatarSize / 2}
8790
height={avatarSize}
91+
justifyContent={justifyContent}
8892
width={avatarSize}
8993
{...rest}
9094
flexDirection="row"
@@ -118,11 +122,6 @@ const styles = StyleSheet.create({
118122
},
119123
});
120124

121-
Avatar.defaultProps = {
122-
alignItems: "center",
123-
justifyContent: "center",
124-
};
125-
126125
Avatar.propTypes = {
127126
/**
128127
* Name to obtain user initials to show as the text in the Avatar.
@@ -144,4 +143,6 @@ Avatar.propTypes = {
144143
* Image to display for the Avatar. It accepts a standard React Native Image source prop Or a function that returns an Image.
145144
*/
146145
imageUrl: PropTypes.string,
146+
alignItems: PropTypes.string,
147+
justifyContent: PropTypes.string,
147148
};

src/components/BottomSheet.jsx

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -143,19 +143,19 @@ Title.propTypes = {
143143
*/
144144

145145
export const BottomSheet = ({
146-
showCreateOption,
147-
CreateItemComponent,
148-
showCreateOptionLoader,
146+
showCreateOption = false,
147+
CreateItemComponent = null,
148+
showCreateOptionLoader = false,
149149
createSearchedOptionLabelStyle,
150-
createOptionLabel,
151-
onPressCreateOption,
150+
createOptionLabel = null,
151+
onPressCreateOption = () => {},
152152
createSearchedOptionContainerStyle,
153153
data = [],
154154
title,
155155
hide,
156156
isVisible,
157157
onItemPress,
158-
bg,
158+
bg = "background.primary",
159159
children,
160160
titleContainerStyle,
161161
titleTextStyle,
@@ -164,17 +164,17 @@ export const BottomSheet = ({
164164
ContentRow,
165165
contentType,
166166
canSearch,
167-
onDonePress,
167+
onDonePress = () => {},
168168
disabled,
169169
noResultsLabelContainerStyle,
170170
noResultsLabelStyle,
171171
noResultsLabel,
172172
NoResultsComponent,
173-
labelExtractor,
174-
valueExtractor,
173+
labelExtractor = () => {},
174+
valueExtractor = () => {},
175175
selectedItem,
176-
onBackdropPress,
177-
searchBarProps,
176+
onBackdropPress = () => {},
177+
searchBarProps = {},
178178
shouldHideKeyboardOnScrollBegin = true,
179179
shouldShowItemSeparator = true,
180180
flatListRef,
@@ -360,20 +360,6 @@ export const BottomSheet = ({
360360
);
361361
};
362362

363-
BottomSheet.defaultProps = {
364-
bg: "background.primary",
365-
showCreateOption: false,
366-
showCreateOptionLoader: false,
367-
createOptionLabel: null,
368-
onPressCreateOption: () => {},
369-
CreateItemComponent: null,
370-
onDonePress: () => {},
371-
valueExtractor: () => {},
372-
labelExtractor: () => {},
373-
onBackdropPress: () => {},
374-
searchBarProps: {},
375-
};
376-
377363
BottomSheet.propTypes = {
378364
/**
379365
* List of items.

src/components/Button.jsx

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -75,17 +75,17 @@ export const BUTTON_VARIANTS = Object.freeze({
7575
export const Button = React.forwardRef(
7676
(
7777
{
78-
variant,
78+
variant = "solid",
7979
label,
8080
labelStyle,
8181
RightIcon,
8282
LeftIcon,
8383
disabled,
84-
isLoading,
85-
loadingText,
84+
isLoading = false,
85+
loadingText = "",
8686
fontFamily,
8787
color,
88-
fontSize,
88+
fontSize = "m",
8989
...rest
9090
},
9191
ref
@@ -224,13 +224,6 @@ export const Button = React.forwardRef(
224224
}
225225
);
226226

227-
Button.defaultProps = {
228-
variant: "solid",
229-
isLoading: false,
230-
loadingText: "",
231-
fontSize: "m",
232-
};
233-
234227
Button.propTypes = {
235228
...propTypes.buttonStyle,
236229
...propTypes.flexbox,

src/components/ButtonGroup.jsx

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ import { Typography } from "./Typography";
3535
*/
3636

3737
export const ButtonGroup = ({
38-
activeColor,
39-
inActiveColor,
38+
activeColor = "background.grey600",
39+
inActiveColor = "background.white",
4040
buttonItems,
4141
onPress,
4242
currentActiveBtn,
43-
wrapperStyle,
44-
buttonStyle,
45-
buttonTextStyle,
43+
wrapperStyle = {},
44+
buttonStyle = {},
45+
buttonTextStyle = { ellipsizeMode: "tail", numberOfLines: 1 },
4646
}) => (
4747
<Container
4848
alignSelf="center"
@@ -78,14 +78,6 @@ export const ButtonGroup = ({
7878
</Container>
7979
);
8080

81-
ButtonGroup.defaultProps = {
82-
activeColor: "background.grey600",
83-
inActiveColor: "background.white",
84-
wrapperStyle: {},
85-
buttonTextStyle: { ellipsizeMode: "tail", numberOfLines: 1 },
86-
buttonStyle: {},
87-
};
88-
8981
ButtonGroup.propTypes = {
9082
/**
9183
* Sets active color to the selected button in buttonGroup.

0 commit comments

Comments
 (0)