Skip to content

Commit 0078fa5

Browse files
authored
Migrate to deprecated-react-native-prop-types package (#2156)
* migrate to deprecated-react-native-prop-types * fix pre-push command name in contributing guide * fix typo in PR template * revert accidential prettier formatting * add explanation to ts-expect-error
1 parent 06ccc92 commit 0078fa5

File tree

13 files changed

+38
-28
lines changed

13 files changed

+38
-28
lines changed

.github/pull_request_template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
*Enter description to help the reviewer understand what's the change about...*
33

44
## Changelog
5-
*Add a quick message for our users about this change (include Compoennt name, relevant props and general purpose of the PR)*
5+
*Add a quick message for our users about this change (include Component name, relevant props and general purpose of the PR)*

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ When contributing to this repository, please first discuss the change you wish t
88
## Pull Request Process
99

1010
1. First make sure the environment is working and synced with master. For installation details go [here](https://github.com/wix/react-native-ui-lib/blob/master/markdowns/getting-started/setup.md#demo-app)
11-
2. Before submitting a PR we suggest running `npm run prepush` command that verifies our lint, TS and tests were not broken.
11+
2. Before submitting a PR we suggest running `npm run pre-push` command that verifies our lint, TS and tests were not broken.
1212
3. Please use our PR prefixes accordingly. `fix` for bugfix, `feat` for feature, `infra` for infrastructure changes and `docs` for documentation related changes (e.g `fix/ButtonStyle`, `feat/Avatar_colorProp`)
1313
4. Please don't change our PR template.
1414
- In the Description section add everything that can help the reviewer and the reviewing process, like a description of the issue and the way you decided to go about it, screenshots or gifs, etc.

demo/src/screens/MainScreen.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import _ from 'lodash';
22
import React, {Component} from 'react';
33
import AsyncStorage from '@react-native-community/async-storage';
44
import PropTypes from 'prop-types';
5-
import {StyleSheet, FlatList, ViewPropTypes} from 'react-native';
5+
import {StyleSheet, FlatList} from 'react-native';
6+
import {ViewPropTypes} from 'deprecated-react-native-prop-types';
67
import {Navigation} from 'react-native-navigation';
78
import {gestureHandlerRootHOC} from 'react-native-gesture-handler';
89
import {

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"babel-plugin-transform-inline-environment-variables": "^0.0.2",
3939
"color": "^3.1.0",
4040
"commons-validator-js": "^1.0.237",
41+
"deprecated-react-native-prop-types": "^2.3.0",
4142
"hoist-non-react-statics": "^3.0.0",
4243
"lodash": "^4.17.21",
4344
"memoize-one": "^5.0.5",

src/components/animatedScanner/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import _ from 'lodash';
22
import PropTypes from 'prop-types';
33
import React from 'react';
4-
import {ViewPropTypes, StyleSheet, Animated} from 'react-native';
4+
import {StyleSheet, Animated} from 'react-native';
5+
import {ViewPropTypes} from 'deprecated-react-native-prop-types';
56
import {Colors} from '../../style';
67
import {BaseComponent} from '../../commons';
78
import View from '../../components/view';

src/components/baseInput/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import _ from 'lodash';
33
import PropTypes from 'prop-types';
44
import 'react';
5-
import {ViewPropTypes, TextInput as RNTextInput} from 'react-native';
5+
import {ViewPropTypes, TextInputPropTypes} from 'deprecated-react-native-prop-types';
66
import {Colors, Typography} from '../../style';
77
import {BaseComponent} from '../../commons';
88
import Validators from './Validators';
@@ -19,7 +19,7 @@ export default class BaseInput extends BaseComponent {
1919
static displayName = 'BaseInput';
2020

2121
static propTypes = {
22-
...RNTextInput.propTypes,
22+
...TextInputPropTypes,
2323
// ...BaseComponent.propTypes,
2424
/**
2525
* text color

src/components/carousel/types.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import React from 'react';
2-
import {ScrollViewProps, StyleProp, ViewStyle, NativeSyntheticEvent, NativeScrollEvent, PointPropType, Animated} from 'react-native';
2+
import {ScrollViewProps, StyleProp, ViewStyle, NativeSyntheticEvent, NativeScrollEvent, Animated} from 'react-native';
3+
// @ts-expect-error No typings available for 'deprecated-react-native-prop-types'
4+
import {PointPropType} from 'deprecated-react-native-prop-types';
35
import {PageControlProps} from '../pageControl';
46

57
export enum PageControlPosition {
@@ -91,7 +93,7 @@ export interface CarouselProps extends ScrollViewProps {
9193
*/
9294
horizontal?: boolean | null;
9395
/**
94-
* Pass to attach to ScrollView's Animated.event in order to animated elements base on
96+
* Pass to attach to ScrollView's Animated.event in order to animated elements base on
9597
* Carousel scroll offset (pass new Animated.ValueXY())
9698
*/
9799
animatedScrollOffset?: Animated.ValueXY;

src/components/image/index.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ import {
66
Image as RNImage,
77
ImageProps as RNImageProps,
88
ImageBackground,
9-
ImageSourcePropType,
109
NativeSyntheticEvent,
1110
ImageErrorEventData
1211
} from 'react-native';
12+
// @ts-expect-error No typings available for 'deprecated-react-native-prop-types'
13+
import {ImagePropTypes} from 'deprecated-react-native-prop-types';
1314
import {
1415
Constants,
1516
asBaseComponent,
@@ -28,7 +29,7 @@ export type ImageProps = RNImageProps &
2829
/**
2930
* custom source transform handler for manipulating the image source (great for size control)
3031
*/
31-
sourceTransformer?: (props: any) => ImageSourcePropType;
32+
sourceTransformer?: (props: any) => ImagePropTypes.source;
3233
/**
3334
* if provided image source will be driven from asset name
3435
*/
@@ -73,7 +74,7 @@ export type ImageProps = RNImageProps &
7374
/**
7475
* Default image source in case of an error
7576
*/
76-
errorSource?: ImageSourcePropType;
77+
errorSource?: ImagePropTypes.source;
7778
/**
7879
* An imageId that can be used in sourceTransformer logic
7980
*/
@@ -90,7 +91,7 @@ type Props = ImageProps & ForwardRefInjectedProps & BaseComponentInjectedProps;
9091

9192
type State = {
9293
error: boolean;
93-
prevSource: ImageSourcePropType;
94+
prevSource: ImagePropTypes.source;
9495
};
9596

9697
/**
@@ -111,7 +112,7 @@ class Image extends PureComponent<Props, State> {
111112
public static overlayTypes = Overlay.overlayTypes;
112113
public static overlayIntensityType = Overlay.intensityTypes;
113114

114-
sourceTransformer?: (props: any) => ImageSourcePropType;
115+
sourceTransformer?: (props: any) => ImagePropTypes.source;
115116

116117
constructor(props: Props) {
117118
super(props);
@@ -149,7 +150,7 @@ class Image extends PureComponent<Props, State> {
149150
return !!overlayType || this.isGif() || !_.isUndefined(customOverlayContent);
150151
}
151152

152-
getVerifiedSource(source?: ImageSourcePropType) {
153+
getVerifiedSource(source?: ImagePropTypes.source) {
153154
if (_.get(source, 'uri') === null || _.get(source, 'uri') === '') {
154155
// @ts-ignore
155156
return {...source, uri: undefined};

src/components/maskedInput/old.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import _ from 'lodash';
22
import PropTypes from 'prop-types';
33
import React from 'react';
4-
import {StyleSheet, ViewPropTypes, Keyboard} from 'react-native';
4+
import {StyleSheet, Keyboard} from 'react-native';
5+
import {ViewPropTypes} from 'deprecated-react-native-prop-types';
56
import BaseInput from '../baseInput';
67
import TextField from '../textField';
78
import View from '../view';

src/components/picker/PickerDialog.android.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React, {Component} from 'react';
2-
import {StyleSheet, Text as RNText} from 'react-native';
2+
import {StyleSheet} from 'react-native';
3+
import {TextPropTypes} from 'deprecated-react-native-prop-types';
34
import PropTypes from 'prop-types';
45
import _ from 'lodash';
56

@@ -17,11 +18,11 @@ class PickerDialog extends Component {
1718
/**
1819
* select label style
1920
*/
20-
selectLabelStyle: RNText.propTypes.style,
21+
selectLabelStyle: TextPropTypes.style,
2122
/**
2223
* cancel label style
2324
*/
24-
cancelLabelStyle: RNText.propTypes.style
25+
cancelLabelStyle: TextPropTypes.style
2526
};
2627

2728
state = {};
@@ -59,8 +60,7 @@ class PickerDialog extends Component {
5960
);
6061
}
6162

62-
63-
render() {
63+
render() {
6464
const {panDirection, visible, pickerModalProps} = this.props;
6565
return (
6666
<Dialog {...pickerModalProps} visible={visible} height="50%" width="77%" panDirection={panDirection}>

0 commit comments

Comments
 (0)