Skip to content

Commit a7b57fe

Browse files
ethansharInbal-Tish
authored andcommitted
rename react unsafe lifecycle methods (wix#409)
* rename react unsafe lifecycle methods * disable camelcase lint for now
1 parent 0722582 commit a7b57fe

File tree

17 files changed

+48
-40
lines changed

17 files changed

+48
-40
lines changed

.eslintrc.js

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,19 @@
44
// const deprecationsJson = require('./eslint-rules/tests/component_deprecation.json');
55

66
module.exports = {
7-
'parser': 'babel-eslint',
8-
'plugins': ['react-native', 'uilib'],
9-
'extends': ['airbnb'],
10-
'rules': {
7+
parser: 'babel-eslint',
8+
plugins: ['react-native', 'uilib'],
9+
extends: ['airbnb'],
10+
rules: {
1111
'arrow-body-style': 'off',
1212
'arrow-parens': 'off',
13+
// TODO: remove after migration of legacy lifecycle methods
14+
'camelcase': 'off',
1315
'class-methods-use-this': 'off',
1416
'consistent-return': 'off',
15-
'comma-dangle': "off",
17+
'comma-dangle': 'off',
1618
'global-require': 'off',
17-
'max-len': [2, 130, 4, {'ignoreUrls': true}],
19+
'max-len': [2, 130, 4, {ignoreUrls: true}],
1820
'no-nested-ternary': 'off',
1921
'no-else-return': 'off',
2022
'no-mixed-operators': ['off'],
@@ -33,31 +35,37 @@ module.exports = {
3335
'react/jsx-tag-spacing': 'off',
3436
// 'react/no-did-mount-set-state': 'warn',
3537
'react/prefer-stateless-function': 'off',
36-
"react/prop-types": ['error', { ignore: ['children', 'style', 'testID'] }],
38+
'react/prop-types': ['error', {ignore: ['children', 'style', 'testID']}],
3739
'react/require-default-props': 'off',
38-
'react/jsx-no-bind': ['warn', {
39-
ignoreRefs: true,
40-
allowArrowFunctions: false,
41-
allowBind: false,
42-
}],
43-
'import/no-extraneous-dependencies': ['warn', {'devDependencies': true, 'optionalDependencies': false, 'peerDependencies': true}],
40+
'react/jsx-no-bind': [
41+
'warn',
42+
{
43+
ignoreRefs: true,
44+
allowArrowFunctions: false,
45+
allowBind: false,
46+
},
47+
],
48+
'import/no-extraneous-dependencies': [
49+
'warn',
50+
{devDependencies: true, optionalDependencies: false, peerDependencies: true},
51+
],
4452
'import/prefer-default-export': 'off',
4553
// 'uilib/assets-deprecation': ['error', {deprecations: assetsDepJson, source: '../../assets', dueDate: '2 November, Friday'}],
4654
// 'uilib/component-deprecation': ['error', {deprecations: deprecationsJson, dueDate: 'Friday 21 December'}],
4755
// 'uilib/no-direct-import': ['error', {origin: 'react-native-ui-lib', destination: 'some-other-source'}],
4856
// 'uilib/no-hard-coded-color': ['error', validColors, extraFixColorsMap],
4957
// 'uilib/no-hard-coded-font': 'error'
5058
},
51-
'env': {
52-
'browser': true,
53-
'node': true,
54-
'jest': true
59+
env: {
60+
browser: true,
61+
node: true,
62+
jest: true,
5563
},
56-
'settings': {
64+
settings: {
5765
'import/resolver': {
58-
'node': {
59-
'extensions': ['.js', '.ios.js', '.android.js']
60-
}
61-
}
62-
}
63-
}
66+
node: {
67+
extensions: ['.js', '.ios.js', '.android.js'],
68+
},
69+
},
70+
},
71+
};

src/commons/SelectableComponent.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export default class SelectableComponent extends BaseComponent {
5656
this.onSelect = this.onSelect.bind(this);
5757
}
5858

59-
componentWillReceiveProps(newProps) {
59+
UNSAFE_componentWillReceiveProps(newProps) {
6060
if (newProps.selected !== this.state.selected) {
6161
this.setState({
6262
selected: newProps.selected,

src/commons/asBaseComponent.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ function asBaseComponent(WrappedComponent) {
99
class BaseComponent extends UIComponent {
1010
state = Modifiers.generateModifiersStyle(undefined, this.props);
1111

12-
componentWillReceiveProps(nextProps) {
12+
UNSAFE_componentWillReceiveProps(nextProps) {
1313
const options = Modifiers.getAlteredModifiersOptions(this.props, nextProps);
1414
if (!_.isEmpty(options)) {
1515
this.setState(Modifiers.generateModifiersStyle(undefined, nextProps));

src/commons/baseComponent.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export default function baseComponent(usePure) {
2828
};
2929
}
3030

31-
componentWillReceiveProps(nextProps) {
31+
UNSAFE_componentWillReceiveProps(nextProps) {
3232
this.updateModifiers(this.props, nextProps);
3333
}
3434

src/components/actionSheet/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export default class ActionSheet extends BaseComponent {
7474
showCancelButton: false,
7575
};
7676

77-
componentWillReceiveProps(nextProps) {
77+
UNSAFE_componentWillReceiveProps(nextProps) {
7878
const {useNativeIOS} = this.getThemeProps();
7979
const wasVisible = this.props.visible;
8080
const willBeVisible = nextProps.visible;

src/components/animatedScanner/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export default class AnimatedScanner extends BaseComponent {
7575
this.styles = createStyles(this.props);
7676
}
7777

78-
componentWillReceiveProps(nextProps) {
78+
UNSAFE_componentWillReceiveProps(nextProps) {
7979
const {progress} = this.props;
8080
if (nextProps.progress !== progress) {
8181
this.animate(nextProps.progress, nextProps.duration);

src/components/featureHighlight/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ class FeatureHighlight extends BaseComponent {
132132
this.setTargetPosition();
133133
}
134134

135-
componentWillReceiveProps(nextProps) {
135+
UNSAFE_componentWillReceiveProps(nextProps) {
136136
this.setTargetPosition(nextProps);
137137
}
138138

src/components/inputs/TextField.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ export default class TextField extends BaseInput {
150150
this.generatePropsWarnings(props);
151151
}
152152

153-
componentWillReceiveProps(nextProps) {
153+
UNSAFE_componentWillReceiveProps(nextProps) {
154154
if (nextProps.value !== this.props.value) {
155155
this.setState({value: nextProps.value}, this.updateFloatingPlaceholderState);
156156
}

src/components/inputs/TextInput.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ export default class TextInput extends BaseInput {
144144
this.generatePropsWarnings(props);
145145
}
146146

147-
componentWillReceiveProps(nextProps) {
147+
UNSAFE_componentWillReceiveProps(nextProps) {
148148
if (nextProps.value !== this.props.value) {
149149
this.setState({value: nextProps.value}, this.updateFloatingPlaceholderState);
150150
}

src/components/picker/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ class Picker extends BaseComponent {
143143
}
144144
}
145145

146-
componentWillReceiveProps(nexProps) {
146+
UNSAFE_componentWillReceiveProps(nexProps) {
147147
this.setState({
148148
value: nexProps.value,
149149
});

src/components/radioButton/RadioGroup.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class RadioGroup extends BaseComponent {
3131
};
3232
}
3333

34-
componentWillReceiveProps(nextProps) {
34+
UNSAFE_componentWillReceiveProps(nextProps) {
3535
if (this.props.value !== nextProps.value) {
3636
this.setState({value: nextProps.value});
3737
}

src/components/switch/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class Switch extends BaseComponent {
7272
this.styles = createStyles(this.getThemeProps());
7373
}
7474

75-
componentWillReceiveProps(nextProps) {
75+
UNSAFE_componentWillReceiveProps(nextProps) {
7676
if (this.props.value !== nextProps.value) {
7777
this.toggle(nextProps.value);
7878
}

src/components/tabBar/TabBarItem.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export default class TabBarItem extends BaseComponent {
8181
};
8282
}
8383

84-
componentWillReceiveProps(nextProps) {
84+
UNSAFE_componentWillReceiveProps(nextProps) {
8585
if (!_.isEqual(nextProps.label, this.props.label) && !_.isEqual(nextProps.width, this.props.width)) {
8686
/** dynamic item's label */
8787
this.setState({fontStyle: this.getFontStyle(this.getThemeProps())});

src/components/tabBar/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ export default class TabBar extends BaseComponent {
124124
this.labels = this.getLabels(this.props.children);
125125
}
126126

127-
componentWillReceiveProps(nextProps) {
127+
UNSAFE_componentWillReceiveProps(nextProps) {
128128
if (React.Children.count(nextProps.children) !== this.childrenCount) {
129129
/** dynamic children count */
130130
this.initializeValues(nextProps);

src/components/tagsInput/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ export default class TagsInput extends BaseComponent {
118118
}
119119
}
120120

121-
componentWillReceiveProps(nextProps) {
121+
UNSAFE_componentWillReceiveProps(nextProps) {
122122
if (nextProps.tags !== this.state.tags) {
123123
this.setState({
124124
tags: nextProps.tags,

src/components/toast/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ export default class Toast extends BaseComponent {
129129
}
130130
}
131131

132-
componentWillReceiveProps(nextProps) {
132+
UNSAFE_componentWillReceiveProps(nextProps) {
133133
const {visible, animated} = nextProps;
134134
const {isVisible} = this.state;
135135
if (visible !== isVisible) {

src/interactableComponents/drawer/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export default class Drawer extends BaseComponent {
9292
};
9393
}
9494

95-
componentWillReceiveProps(nextProps) {
95+
UNSAFE_componentWillReceiveProps(nextProps) {
9696
if (JSON.stringify(this.props.leftItem) !== JSON.stringify(nextProps.leftItem) ||
9797
JSON.stringify(this.props.rightItems) !== JSON.stringify(nextProps.rightItems)) {
9898
this.closeDrawer();

0 commit comments

Comments
 (0)