Skip to content

Commit 6f007e8

Browse files
Brian Vaughnfacebook-github-bot
Brian Vaughn
authored andcommitted
Ran rename-unsafe-lifecycles codemod on xplat/js
Reviewed By: trueadm Differential Revision: D6889214 fbshipit-source-id: e815cda4b09f3650ae3b0b9a44ae6f5fcb48fe25
1 parent fa334ce commit 6f007e8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+75
-66
lines changed

IntegrationTests/ReactContentSizeUpdateTest.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ var ReactContentSizeUpdateTest = createReactClass({
3030
mixins: [Subscribable.Mixin,
3131
TimerMixin],
3232

33-
componentWillMount: function() {
33+
UNSAFE_componentWillMount: function() {
3434
this.addListenerOn(
3535
RCTNativeAppEventEmitter,
3636
'rootViewDidChangeIntrinsicSize',

IntegrationTests/SizeFlexibilityUpdateTest.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ var SizeFlexibilityUpdateTest = createReactClass({
2727
displayName: 'SizeFlexibilityUpdateTest',
2828
mixins: [Subscribable.Mixin],
2929

30-
componentWillMount: function() {
30+
UNSAFE_componentWillMount: function() {
3131
this.addListenerOn(
3232
RCTNativeAppEventEmitter,
3333
'rootViewDidChangeIntrinsicSize',

Libraries/Animated/src/__tests__/Animated-test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,11 @@ describe('Animated tests', () => {
9494
opacity: anim,
9595
},
9696
};
97-
c.componentWillMount();
97+
c.UNSAFE_componentWillMount();
9898

9999
expect(anim.__detach).not.toBeCalled();
100100
c._component = {};
101-
c.componentWillReceiveProps({
101+
c.UNSAFE_componentWillReceiveProps({
102102
style: {
103103
opacity: anim,
104104
},
@@ -120,7 +120,7 @@ describe('Animated tests', () => {
120120
opacity: anim,
121121
},
122122
};
123-
c.componentWillMount();
123+
c.UNSAFE_componentWillMount();
124124

125125
Animated.timing(anim, {toValue: 10, duration: 1000}).start(callback);
126126
c._component = {};

Libraries/Animated/src/__tests__/AnimatedNative-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const NativeAnimatedHelper = require('NativeAnimatedHelper');
2929
function createAndMountComponent(ComponentClass, props) {
3030
const component = new ComponentClass();
3131
component.props = props;
32-
component.componentWillMount();
32+
component.UNSAFE_componentWillMount();
3333
// Simulate that refs were set.
3434
component._component = {};
3535
component.componentDidMount();

Libraries/Animated/src/createAnimatedComponent.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function createAnimatedComponent(Component: any): any {
4242
this._component.setNativeProps(props);
4343
}
4444

45-
componentWillMount() {
45+
UNSAFE_componentWillMount() {
4646
this._attachProps(this.props);
4747
}
4848

@@ -127,7 +127,7 @@ function createAnimatedComponent(Component: any): any {
127127
oldPropsAnimated && oldPropsAnimated.__detach();
128128
}
129129

130-
componentWillReceiveProps(newProps) {
130+
UNSAFE_componentWillReceiveProps(newProps) {
131131
this._attachProps(newProps);
132132
}
133133

Libraries/Components/Keyboard/KeyboardAvoidingView.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ const KeyboardAvoidingView = createReactClass({
133133
this.frame = event.nativeEvent.layout;
134134
},
135135

136-
componentWillUpdate(nextProps: Object, nextState: Object, nextContext?: Object): void {
136+
UNSAFE_componentWillUpdate(nextProps: Object, nextState: Object, nextContext?: Object): void {
137137
if (nextState.bottom === this.state.bottom &&
138138
this.props.behavior === 'height' &&
139139
nextProps.behavior === 'height') {
@@ -143,7 +143,7 @@ const KeyboardAvoidingView = createReactClass({
143143
}
144144
},
145145

146-
componentWillMount() {
146+
UNSAFE_componentWillMount() {
147147
if (Platform.OS === 'ios') {
148148
this.subscriptions = [
149149
Keyboard.addListener('keyboardWillChangeFrame', this._onKeyboardChange),

Libraries/Components/LazyRenderer.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ var LazyRenderer = createReactClass({
2323
render: PropTypes.func.isRequired,
2424
},
2525

26-
componentWillMount: function(): void {
26+
UNSAFE_componentWillMount: function(): void {
2727
this.setState({
2828
_lazyRender : true,
2929
});

Libraries/Components/Navigation/NavigatorIOS.ios.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ var NavigatorIOS = createReactClass({
515515

516516
navigator: (undefined: ?Object),
517517

518-
componentWillMount: function() {
518+
UNSAFE_componentWillMount: function() {
519519
// Precompute a pack of callbacks that's frequently generated and passed to
520520
// instances.
521521
this.navigator = {

Libraries/Components/Picker/PickerAndroid.android.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class PickerAndroid extends React.Component<{
6666
};
6767
}
6868

69-
componentWillReceiveProps(nextProps) {
69+
UNSAFE_componentWillReceiveProps(nextProps) {
7070
this.setState(this._stateFromProps(nextProps));
7171
}
7272

Libraries/Components/Picker/PickerIOS.ios.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ var PickerIOS = createReactClass({
4141
return this._stateFromProps(this.props);
4242
},
4343

44-
componentWillReceiveProps: function(nextProps) {
44+
UNSAFE_componentWillReceiveProps: function(nextProps) {
4545
this.setState(this._stateFromProps(nextProps));
4646
},
4747

Libraries/Components/ScrollResponder.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ const ScrollResponderMixin = {
548548
*
549549
* The `keyboardWillShow` is called before input focus.
550550
*/
551-
componentWillMount: function() {
551+
UNSAFE_componentWillMount: function() {
552552
const {keyboardShouldPersistTaps} = this.props;
553553
warning(
554554
typeof keyboardShouldPersistTaps !== 'boolean',

Libraries/Components/ScrollView/ScrollView.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ const ScrollView = createReactClass({
510510
};
511511
},
512512

513-
componentWillMount: function() {
513+
UNSAFE_componentWillMount: function() {
514514
this._scrollAnimatedValue = new Animated.Value(this.props.contentOffset ? this.props.contentOffset.y : 0);
515515
this._scrollAnimatedValue.setOffset(this.props.contentInset ? this.props.contentInset.top : 0);
516516
this._stickyHeaderRefs = new Map();

Libraries/Components/Subscribable.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ var Subscribable = {};
2525

2626
Subscribable.Mixin = {
2727

28-
componentWillMount: function() {
28+
UNSAFE_componentWillMount: function() {
2929
this._subscribableSubscriptions = [];
3030
},
3131

Libraries/Components/TabBarIOS/TabBarItemIOS.ios.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,13 @@ class TabBarItemIOS extends React.Component {
102102
hasBeenSelected: false,
103103
};
104104

105-
componentWillMount() {
105+
UNSAFE_componentWillMount() {
106106
if (this.props.selected) {
107107
this.setState({hasBeenSelected: true});
108108
}
109109
}
110110

111-
componentWillReceiveProps(nextProps: { selected?: boolean }) {
111+
UNSAFE_componentWillReceiveProps(nextProps: { selected?: boolean }) {
112112
if (this.state.hasBeenSelected || nextProps.selected) {
113113
this.setState({hasBeenSelected: true});
114114
}

Libraries/Components/Touchable/TouchableHighlight.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ const TouchableHighlight = createReactClass({
203203
clearTimeout(this._hideTimeout);
204204
},
205205

206-
componentWillReceiveProps: function(nextProps) {
206+
UNSAFE_componentWillReceiveProps: function(nextProps) {
207207
ensurePositiveDelayProps(nextProps);
208208
},
209209

Libraries/Components/Touchable/TouchableNativeFeedback.android.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ var TouchableNativeFeedback = createReactClass({
147147
ensurePositiveDelayProps(this.props);
148148
},
149149

150-
componentWillReceiveProps: function(nextProps) {
150+
UNSAFE_componentWillReceiveProps: function(nextProps) {
151151
ensurePositiveDelayProps(nextProps);
152152
},
153153

Libraries/Components/Touchable/TouchableOpacity.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ var TouchableOpacity = createReactClass({
158158
ensurePositiveDelayProps(this.props);
159159
},
160160

161-
componentWillReceiveProps: function(nextProps) {
161+
UNSAFE_componentWillReceiveProps: function(nextProps) {
162162
ensurePositiveDelayProps(nextProps);
163163
},
164164

Libraries/Components/Touchable/TouchableWithoutFeedback.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ const TouchableWithoutFeedback = createReactClass({
122122
ensurePositiveDelayProps(this.props);
123123
},
124124

125-
componentWillReceiveProps: function(nextProps: Object) {
125+
UNSAFE_componentWillReceiveProps: function(nextProps: Object) {
126126
ensurePositiveDelayProps(nextProps);
127127
},
128128

Libraries/Components/WebView/WebView.android.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ class WebView extends React.Component {
247247
startInLoadingState: true,
248248
};
249249

250-
componentWillMount() {
250+
UNSAFE_componentWillMount() {
251251
if (this.props.startInLoadingState) {
252252
this.setState({viewState: WebViewState.LOADING});
253253
}

Libraries/Components/WebView/WebView.ios.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ class WebView extends React.Component {
410410
startInLoadingState: true,
411411
};
412412

413-
componentWillMount() {
413+
UNSAFE_componentWillMount() {
414414
if (this.props.startInLoadingState) {
415415
this.setState({viewState: WebViewState.LOADING});
416416
}

Libraries/Experimental/Incremental.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ class Incremental extends React.Component<Props, State> {
129129
return ctx.groupId + ':' + this._incrementId + '-' + this.props.name;
130130
}
131131

132-
componentWillMount() {
132+
UNSAFE_componentWillMount() {
133133
const ctx = this.context.incrementalGroup;
134134
if (!ctx) {
135135
return;

Libraries/Experimental/IncrementalGroup.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import type {Props, Context} from 'Incremental';
3737
class IncrementalGroup extends React.Component<Props & {disabled?: boolean}> {
3838
context: Context;
3939
_groupInc: string;
40-
componentWillMount() {
40+
UNSAFE_componentWillMount() {
4141
this._groupInc = `g${++_groupCounter}-`;
4242
DEBUG && infoLog(
4343
'create IncrementalGroup with id ' + this.getGroupId()

Libraries/Experimental/SwipeableRow/SwipeableListView.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ class SwipeableListView extends React.Component<Props, State> {
105105
};
106106
}
107107

108-
componentWillReceiveProps(nextProps: Props): void {
108+
UNSAFE_componentWillReceiveProps(nextProps: Props): void {
109109
if (this.state.dataSource.getDataSource() !== nextProps.dataSource.getDataSource()) {
110110
this.setState({
111111
dataSource: nextProps.dataSource,

Libraries/Experimental/SwipeableRow/SwipeableRow.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ const SwipeableRow = createReactClass({
125125
};
126126
},
127127

128-
componentWillMount(): void {
128+
UNSAFE_componentWillMount(): void {
129129
this._panResponder = PanResponder.create({
130130
onMoveShouldSetPanResponderCapture: this._handleMoveShouldSetPanResponderCapture,
131131
onPanResponderGrant: this._handlePanResponderGrant,
@@ -149,7 +149,7 @@ const SwipeableRow = createReactClass({
149149
}
150150
},
151151

152-
componentWillReceiveProps(nextProps: Object): void {
152+
UNSAFE_componentWillReceiveProps(nextProps: Object): void {
153153
/**
154154
* We do not need an "animateOpen(noCallback)" because this animation is
155155
* handled internally by this component.

Libraries/Experimental/WindowedListView.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ class WindowedListView extends React.Component<Props, State> {
243243
DEBUG && infoLog(' knope');
244244
return false;
245245
}
246-
componentWillReceiveProps() {
246+
UNSAFE_componentWillReceiveProps() {
247247
this._computeRowsToRenderBatcher.schedule();
248248
}
249249
_onMomentumScrollEnd = (e: Object) => {
@@ -624,7 +624,7 @@ class CellRenderer extends React.Component<CellProps> {
624624
_perfUpdateID: number = 0;
625625
_asyncCookie: any;
626626
_includeInLayoutLatch: boolean = false;
627-
componentWillMount() {
627+
UNSAFE_componentWillMount() {
628628
if (this.props.asyncRowPerfEventName) {
629629
this._perfUpdateID = g_perf_update_id++;
630630
this._asyncCookie = Systrace.beginAsyncEvent(
@@ -694,7 +694,7 @@ class CellRenderer extends React.Component<CellProps> {
694694
this.props.onProgressChange({rowKey: this.props.rowKey, inProgress: false});
695695
this.props.onWillUnmount(this.props.rowKey);
696696
}
697-
componentWillReceiveProps(newProps) {
697+
UNSAFE_componentWillReceiveProps(newProps) {
698698
if (newProps.includeInLayout && !this.props.includeInLayout) {
699699
invariant(this._offscreenRenderDone, 'Should never try to add to layout before render done');
700700
this._includeInLayoutLatch = true; // Once we render in layout, make sure it sticks.

Libraries/Inspector/Inspector.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class Inspector extends React.Component<{
9292
hook.off('react-devtools', this.attachToDevtools);
9393
}
9494

95-
componentWillReceiveProps(newProps: Object) {
95+
UNSAFE_componentWillReceiveProps(newProps: Object) {
9696
this.setState({inspectedViewTag: newProps.inspectedViewTag});
9797
}
9898

Libraries/Lists/FlatList.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -423,11 +423,11 @@ class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
423423
}
424424
}
425425

426-
componentWillMount() {
426+
UNSAFE_componentWillMount() {
427427
this._checkProps(this.props);
428428
}
429429

430-
componentWillReceiveProps(nextProps: Props<ItemT>) {
430+
UNSAFE_componentWillReceiveProps(nextProps: Props<ItemT>) {
431431
invariant(
432432
nextProps.numColumns === this.props.numColumns,
433433
'Changing numColumns on the fly is not supported. Change the key prop on FlatList when ' +

Libraries/Lists/ListView/ListView.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ var ListView = createReactClass({
354354
return this._scrollComponent.getInnerViewNode();
355355
},
356356

357-
componentWillMount: function() {
357+
UNSAFE_componentWillMount: function() {
358358
// this data should never trigger a render pass, so don't put in state
359359
this.scrollProperties = {
360360
visibleLength: null,
@@ -375,7 +375,7 @@ var ListView = createReactClass({
375375
});
376376
},
377377

378-
componentWillReceiveProps: function(nextProps: Object) {
378+
UNSAFE_componentWillReceiveProps: function(nextProps: Object) {
379379
if (
380380
this.props.dataSource !== nextProps.dataSource ||
381381
this.props.initialListSize !== nextProps.initialListSize

Libraries/Lists/MetroListView.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ class MetroListView extends React.Component<Props, $FlowFixMeState> {
135135
}),
136136
sectionHeaderData: {},
137137
});
138-
componentWillReceiveProps(newProps: Props) {
138+
UNSAFE_componentWillReceiveProps(newProps: Props) {
139139
this.setState(state => this._computeState(newProps, state));
140140
}
141141
render() {

Libraries/Lists/VirtualizedList.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
611611
this._fillRateHelper.deactivateAndFlush();
612612
}
613613

614-
componentWillReceiveProps(newProps: Props) {
614+
UNSAFE_componentWillReceiveProps(newProps: Props) {
615615
const {data, extraData, getItemCount, maxToRenderPerBatch} = newProps;
616616
// first and last could be stale (e.g. if a new, shorter items props is passed in), so we make
617617
// sure we're rendering a reasonable range here.

Libraries/Lists/VirtualizedSectionList.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ class VirtualizedSectionList<SectionT: SectionBase> extends React.PureComponent<
361361
this.state = this._computeState(props);
362362
}
363363

364-
componentWillReceiveProps(nextProps: Props<SectionT>) {
364+
UNSAFE_componentWillReceiveProps(nextProps: Props<SectionT>) {
365365
this.setState(this._computeState(nextProps));
366366
}
367367

@@ -446,7 +446,7 @@ class ItemWithSeparator extends React.Component<
446446
},
447447
};
448448

449-
componentWillReceiveProps(props: ItemWithSeparatorProps) {
449+
UNSAFE_componentWillReceiveProps(props: ItemWithSeparatorProps) {
450450
this.setState(state => ({
451451
separatorProps: {
452452
...this.state.separatorProps,

Libraries/Modal/Modal.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ class Modal extends React.Component<Object> {
151151
}
152152
}
153153

154-
componentWillReceiveProps(nextProps: Object) {
154+
UNSAFE_componentWillReceiveProps(nextProps: Object) {
155155
Modal._confirmProps(nextProps);
156156
}
157157

RNTester/js/AnimatedGratuitousApp/AnExSet.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class AnExSet extends React.Component<Object, any> {
7575
);
7676
}
7777

78-
componentWillMount() {
78+
UNSAFE_componentWillMount() {
7979
this.state.dismissY = new Animated.Value(0);
8080
this.state.dismissResponder = PanResponder.create({
8181
onStartShouldSetPanResponder: () => this.props.isActive,

RNTester/js/AnimatedGratuitousApp/AnExTilt.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class AnExTilt extends React.Component<Object, any> {
7777
}).start();
7878
}
7979

80-
componentWillMount() {
80+
UNSAFE_componentWillMount() {
8181
this._startBurnsZoom();
8282
}
8383

0 commit comments

Comments
 (0)