Skip to content

Commit c39e74e

Browse files
authored
Components defaultProps migrate to default parameters (#3311)
1 parent b4fd1d8 commit c39e74e

File tree

5 files changed

+20
-29
lines changed

5 files changed

+20
-29
lines changed

src/components/dash/index.tsx

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@ export type Layout = {
1212

1313
export interface DashProps extends ViewProps {
1414
vertical?: boolean;
15-
gap: number;
16-
length: number;
17-
thickness: number;
15+
gap?: number;
16+
length?: number;
17+
thickness?: number;
1818
color?: string;
1919
style?: StyleProp<ViewStyle>;
2020
containerStyle?: StyleProp<ViewStyle>;
2121
}
2222

2323
const Dash = (props: DashProps) => {
24-
const {containerStyle, vertical, gap, length, thickness, color, style, testID} = props;
24+
const {containerStyle, vertical, gap = 6, length = 6, thickness = 2, color, style, testID} = props;
2525
const [measurements, setMeasurements] = useState<Layout | undefined>();
2626

2727
const onDashLayout = useCallback((event: LayoutChangeEvent) => {
@@ -52,7 +52,7 @@ const Dash = (props: DashProps) => {
5252
const _length = (vertical ? measurements?.height : measurements?.width) || 0;
5353
const n = Math.ceil(_length / (gap + length));
5454
const dash = [];
55-
55+
5656
for (let i = 0; i < n; i++) {
5757
dash.push(<View key={i} bg-$outlineDefault backgroundColor={color} style={dashStyle}/>);
5858
}
@@ -68,11 +68,6 @@ const Dash = (props: DashProps) => {
6868
};
6969

7070
export default Dash;
71-
Dash.defaultProps = {
72-
gap: 6,
73-
length: 6,
74-
thickness: 2
75-
};
7671

7772
const styles = StyleSheet.create({
7873
row: {

src/components/dialog/DialogDismissibleView.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,14 @@ interface LocationProps {
5757
const DEFAULT_DIRECTION = PanningProvider.Directions.DOWN;
5858

5959
const DialogDismissibleView = (props: Props) => {
60-
const {direction = DEFAULT_DIRECTION, visible: propsVisible, containerStyle, style, children, onDismiss} = props;
60+
const {
61+
direction = DEFAULT_DIRECTION,
62+
visible: propsVisible,
63+
containerStyle,
64+
style,
65+
children,
66+
onDismiss = () => {}
67+
} = props;
6168
// @ts-expect-error
6269
const {isPanning, dragDeltas, swipeDirections} = useContext<PanContextProps>(PanningContext);
6370

@@ -245,10 +252,6 @@ const DialogDismissibleView = (props: Props) => {
245252
};
246253

247254
DialogDismissibleView.displayName = 'IGNORE';
248-
DialogDismissibleView.defaultProps = {
249-
direction: DEFAULT_DIRECTION,
250-
onDismiss: () => {}
251-
};
252255

253256
export default DialogDismissibleView;
254257

src/components/icon/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ const Icon = forwardRef((props: Props, ref: any) => {
5656
style,
5757
supportRTL,
5858
source,
59-
assetGroup,
59+
assetGroup = 'icons',
6060
assetName,
6161
modifiers,
6262
recorderTag,

src/components/picker/index.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ type PickerStatics = {
4747
const Picker = React.forwardRef((props: PickerProps, ref) => {
4848
const themeProps = useThemeProps(props, 'Picker');
4949
const {
50-
mode,
50+
mode = PickerModes.SINGLE,
5151
fieldType = PickerFieldTypes.form,
5252
selectionLimit,
5353
showSearch,
@@ -86,10 +86,10 @@ const Picker = React.forwardRef((props: PickerProps, ref) => {
8686
const [items, setItems] = useState<PickerItemProps[]>(propItems || extractPickerItems(themeProps));
8787
const pickerExpandable = useRef<ExpandableOverlayMethods>(null);
8888
const pickerRef = useImperativePickerHandle(ref, pickerExpandable);
89-
89+
9090
// TODO: Remove this when migration is completed, starting of v8
9191
// usePickerMigrationWarnings({children, migrate, getItemLabel, getItemValue});
92-
92+
9393
useEffect(() => {
9494
if (propItems) {
9595
setItems(propItems);
@@ -295,9 +295,7 @@ const Picker = React.forwardRef((props: PickerProps, ref) => {
295295

296296
// @ts-expect-error
297297
Picker.Item = PickerItem;
298-
Picker.defaultProps = {
299-
mode: PickerModes.SINGLE
300-
};
298+
301299
Picker.displayName = 'Picker';
302300
// @ts-expect-error
303301
Picker.modes = PickerModes;

src/components/stackAggregator/index.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ const StackAggregator = (props: StackAggregatorProps) => {
6868
containerStyle,
6969
buttonProps,
7070
collapsed = true,
71-
disablePresses,
71+
disablePresses = false,
7272
onItemPress,
7373
contentContainerStyle,
74-
itemBorderRadius,
74+
itemBorderRadius = 0,
7575
onCollapseWillChange,
7676
onCollapseChanged
7777
} = props;
@@ -301,11 +301,6 @@ const StackAggregator = (props: StackAggregatorProps) => {
301301

302302
export default asBaseComponent<StackAggregatorProps>(StackAggregator);
303303
StackAggregator.displayName = 'StackAggregator';
304-
StackAggregator.defaultProps = {
305-
collapsed: true,
306-
disablePresses: false,
307-
itemBorderRadius: 0
308-
};
309304

310305
const styles = StyleSheet.create({
311306
subContainer: {

0 commit comments

Comments
 (0)