From 6f007e8957c9bf5652b0184cba65f385050a8236 Mon Sep 17 00:00:00 2001 From: Brian Vaughn Date: Thu, 8 Feb 2018 10:26:45 -0800 Subject: [PATCH] Ran rename-unsafe-lifecycles codemod on xplat/js Reviewed By: trueadm Differential Revision: D6889214 fbshipit-source-id: e815cda4b09f3650ae3b0b9a44ae6f5fcb48fe25 --- IntegrationTests/ReactContentSizeUpdateTest.js | 2 +- IntegrationTests/SizeFlexibilityUpdateTest.js | 2 +- Libraries/Animated/src/__tests__/Animated-test.js | 6 +++--- .../Animated/src/__tests__/AnimatedNative-test.js | 2 +- Libraries/Animated/src/createAnimatedComponent.js | 4 ++-- Libraries/Components/Keyboard/KeyboardAvoidingView.js | 4 ++-- Libraries/Components/LazyRenderer.js | 2 +- Libraries/Components/Navigation/NavigatorIOS.ios.js | 2 +- Libraries/Components/Picker/PickerAndroid.android.js | 2 +- Libraries/Components/Picker/PickerIOS.ios.js | 2 +- Libraries/Components/ScrollResponder.js | 2 +- Libraries/Components/ScrollView/ScrollView.js | 2 +- Libraries/Components/Subscribable.js | 2 +- Libraries/Components/TabBarIOS/TabBarItemIOS.ios.js | 4 ++-- Libraries/Components/Touchable/TouchableHighlight.js | 2 +- .../Touchable/TouchableNativeFeedback.android.js | 2 +- Libraries/Components/Touchable/TouchableOpacity.js | 2 +- .../Components/Touchable/TouchableWithoutFeedback.js | 2 +- Libraries/Components/WebView/WebView.android.js | 2 +- Libraries/Components/WebView/WebView.ios.js | 2 +- Libraries/Experimental/Incremental.js | 2 +- Libraries/Experimental/IncrementalGroup.js | 2 +- .../Experimental/SwipeableRow/SwipeableListView.js | 2 +- Libraries/Experimental/SwipeableRow/SwipeableRow.js | 4 ++-- Libraries/Experimental/WindowedListView.js | 6 +++--- Libraries/Inspector/Inspector.js | 2 +- Libraries/Lists/FlatList.js | 4 ++-- Libraries/Lists/ListView/ListView.js | 4 ++-- Libraries/Lists/MetroListView.js | 2 +- Libraries/Lists/VirtualizedList.js | 2 +- Libraries/Lists/VirtualizedSectionList.js | 4 ++-- Libraries/Modal/Modal.js | 2 +- RNTester/js/AnimatedGratuitousApp/AnExSet.js | 2 +- RNTester/js/AnimatedGratuitousApp/AnExTilt.js | 2 +- RNTester/js/CameraRollView.js | 2 +- RNTester/js/ImageExample.js | 2 +- RNTester/js/LayoutAnimationExample.js | 2 +- RNTester/js/ListViewExample.js | 2 +- RNTester/js/ListViewGridLayoutExample.js | 2 +- RNTester/js/ListViewPagingExample.js | 2 +- RNTester/js/PanResponderExample.js | 2 +- RNTester/js/PushNotificationIOSExample.js | 2 +- RNTester/js/RNTesterApp.android.js | 2 +- RNTester/js/RNTesterApp.ios.js | 2 +- RNTester/js/RNTesterSettingSwitchRow.js | 2 +- RNTester/js/SwipeableListViewExample.js | 2 +- RNTester/js/TextInputExample.android.js | 2 +- RNTester/js/TextInputExample.ios.js | 2 +- ReactAndroid/src/androidTest/js/JSResponderTestApp.js | 2 +- .../src/androidTest/js/PickerAndroidTestModule.js | 2 +- .../src/androidTest/js/SubviewsClippingTestModule.js | 2 +- .../HelloNavigation/components/KeyboardSpacer.js | 11 ++++++++++- package.json | 6 +++--- 53 files changed, 75 insertions(+), 66 deletions(-) diff --git a/IntegrationTests/ReactContentSizeUpdateTest.js b/IntegrationTests/ReactContentSizeUpdateTest.js index 07ae0ed661ce15..3524ef92ed385e 100644 --- a/IntegrationTests/ReactContentSizeUpdateTest.js +++ b/IntegrationTests/ReactContentSizeUpdateTest.js @@ -30,7 +30,7 @@ var ReactContentSizeUpdateTest = createReactClass({ mixins: [Subscribable.Mixin, TimerMixin], - componentWillMount: function() { + UNSAFE_componentWillMount: function() { this.addListenerOn( RCTNativeAppEventEmitter, 'rootViewDidChangeIntrinsicSize', diff --git a/IntegrationTests/SizeFlexibilityUpdateTest.js b/IntegrationTests/SizeFlexibilityUpdateTest.js index 5d580f8fc6a028..77895f40006498 100644 --- a/IntegrationTests/SizeFlexibilityUpdateTest.js +++ b/IntegrationTests/SizeFlexibilityUpdateTest.js @@ -27,7 +27,7 @@ var SizeFlexibilityUpdateTest = createReactClass({ displayName: 'SizeFlexibilityUpdateTest', mixins: [Subscribable.Mixin], - componentWillMount: function() { + UNSAFE_componentWillMount: function() { this.addListenerOn( RCTNativeAppEventEmitter, 'rootViewDidChangeIntrinsicSize', diff --git a/Libraries/Animated/src/__tests__/Animated-test.js b/Libraries/Animated/src/__tests__/Animated-test.js index 1ddbb38d559f06..c8f2b94223df26 100644 --- a/Libraries/Animated/src/__tests__/Animated-test.js +++ b/Libraries/Animated/src/__tests__/Animated-test.js @@ -94,11 +94,11 @@ describe('Animated tests', () => { opacity: anim, }, }; - c.componentWillMount(); + c.UNSAFE_componentWillMount(); expect(anim.__detach).not.toBeCalled(); c._component = {}; - c.componentWillReceiveProps({ + c.UNSAFE_componentWillReceiveProps({ style: { opacity: anim, }, @@ -120,7 +120,7 @@ describe('Animated tests', () => { opacity: anim, }, }; - c.componentWillMount(); + c.UNSAFE_componentWillMount(); Animated.timing(anim, {toValue: 10, duration: 1000}).start(callback); c._component = {}; diff --git a/Libraries/Animated/src/__tests__/AnimatedNative-test.js b/Libraries/Animated/src/__tests__/AnimatedNative-test.js index 08388069d59ef4..d3f59368ea6098 100644 --- a/Libraries/Animated/src/__tests__/AnimatedNative-test.js +++ b/Libraries/Animated/src/__tests__/AnimatedNative-test.js @@ -29,7 +29,7 @@ const NativeAnimatedHelper = require('NativeAnimatedHelper'); function createAndMountComponent(ComponentClass, props) { const component = new ComponentClass(); component.props = props; - component.componentWillMount(); + component.UNSAFE_componentWillMount(); // Simulate that refs were set. component._component = {}; component.componentDidMount(); diff --git a/Libraries/Animated/src/createAnimatedComponent.js b/Libraries/Animated/src/createAnimatedComponent.js index 2e10a6c71427e3..fd363ff0ca7495 100644 --- a/Libraries/Animated/src/createAnimatedComponent.js +++ b/Libraries/Animated/src/createAnimatedComponent.js @@ -42,7 +42,7 @@ function createAnimatedComponent(Component: any): any { this._component.setNativeProps(props); } - componentWillMount() { + UNSAFE_componentWillMount() { this._attachProps(this.props); } @@ -127,7 +127,7 @@ function createAnimatedComponent(Component: any): any { oldPropsAnimated && oldPropsAnimated.__detach(); } - componentWillReceiveProps(newProps) { + UNSAFE_componentWillReceiveProps(newProps) { this._attachProps(newProps); } diff --git a/Libraries/Components/Keyboard/KeyboardAvoidingView.js b/Libraries/Components/Keyboard/KeyboardAvoidingView.js index 8c6c8964b5b8df..0ee09ea9c3086a 100644 --- a/Libraries/Components/Keyboard/KeyboardAvoidingView.js +++ b/Libraries/Components/Keyboard/KeyboardAvoidingView.js @@ -133,7 +133,7 @@ const KeyboardAvoidingView = createReactClass({ this.frame = event.nativeEvent.layout; }, - componentWillUpdate(nextProps: Object, nextState: Object, nextContext?: Object): void { + UNSAFE_componentWillUpdate(nextProps: Object, nextState: Object, nextContext?: Object): void { if (nextState.bottom === this.state.bottom && this.props.behavior === 'height' && nextProps.behavior === 'height') { @@ -143,7 +143,7 @@ const KeyboardAvoidingView = createReactClass({ } }, - componentWillMount() { + UNSAFE_componentWillMount() { if (Platform.OS === 'ios') { this.subscriptions = [ Keyboard.addListener('keyboardWillChangeFrame', this._onKeyboardChange), diff --git a/Libraries/Components/LazyRenderer.js b/Libraries/Components/LazyRenderer.js index 2d2c225f52ab67..3f026273556e07 100644 --- a/Libraries/Components/LazyRenderer.js +++ b/Libraries/Components/LazyRenderer.js @@ -23,7 +23,7 @@ var LazyRenderer = createReactClass({ render: PropTypes.func.isRequired, }, - componentWillMount: function(): void { + UNSAFE_componentWillMount: function(): void { this.setState({ _lazyRender : true, }); diff --git a/Libraries/Components/Navigation/NavigatorIOS.ios.js b/Libraries/Components/Navigation/NavigatorIOS.ios.js index fe90fb9f611f46..9a5596fe383bda 100644 --- a/Libraries/Components/Navigation/NavigatorIOS.ios.js +++ b/Libraries/Components/Navigation/NavigatorIOS.ios.js @@ -515,7 +515,7 @@ var NavigatorIOS = createReactClass({ navigator: (undefined: ?Object), - componentWillMount: function() { + UNSAFE_componentWillMount: function() { // Precompute a pack of callbacks that's frequently generated and passed to // instances. this.navigator = { diff --git a/Libraries/Components/Picker/PickerAndroid.android.js b/Libraries/Components/Picker/PickerAndroid.android.js index bc5890657d1ee2..35aea2b33581b0 100644 --- a/Libraries/Components/Picker/PickerAndroid.android.js +++ b/Libraries/Components/Picker/PickerAndroid.android.js @@ -66,7 +66,7 @@ class PickerAndroid extends React.Component<{ }; } - componentWillReceiveProps(nextProps) { + UNSAFE_componentWillReceiveProps(nextProps) { this.setState(this._stateFromProps(nextProps)); } diff --git a/Libraries/Components/Picker/PickerIOS.ios.js b/Libraries/Components/Picker/PickerIOS.ios.js index 81911b4bc16143..5d58c00cfc939a 100644 --- a/Libraries/Components/Picker/PickerIOS.ios.js +++ b/Libraries/Components/Picker/PickerIOS.ios.js @@ -41,7 +41,7 @@ var PickerIOS = createReactClass({ return this._stateFromProps(this.props); }, - componentWillReceiveProps: function(nextProps) { + UNSAFE_componentWillReceiveProps: function(nextProps) { this.setState(this._stateFromProps(nextProps)); }, diff --git a/Libraries/Components/ScrollResponder.js b/Libraries/Components/ScrollResponder.js index 5b3244d3eea910..e44f21f4fc005d 100644 --- a/Libraries/Components/ScrollResponder.js +++ b/Libraries/Components/ScrollResponder.js @@ -548,7 +548,7 @@ const ScrollResponderMixin = { * * The `keyboardWillShow` is called before input focus. */ - componentWillMount: function() { + UNSAFE_componentWillMount: function() { const {keyboardShouldPersistTaps} = this.props; warning( typeof keyboardShouldPersistTaps !== 'boolean', diff --git a/Libraries/Components/ScrollView/ScrollView.js b/Libraries/Components/ScrollView/ScrollView.js index 964421282ba25b..43e89b5ab74672 100644 --- a/Libraries/Components/ScrollView/ScrollView.js +++ b/Libraries/Components/ScrollView/ScrollView.js @@ -510,7 +510,7 @@ const ScrollView = createReactClass({ }; }, - componentWillMount: function() { + UNSAFE_componentWillMount: function() { this._scrollAnimatedValue = new Animated.Value(this.props.contentOffset ? this.props.contentOffset.y : 0); this._scrollAnimatedValue.setOffset(this.props.contentInset ? this.props.contentInset.top : 0); this._stickyHeaderRefs = new Map(); diff --git a/Libraries/Components/Subscribable.js b/Libraries/Components/Subscribable.js index 8474b214994f4b..0244ad673c2404 100644 --- a/Libraries/Components/Subscribable.js +++ b/Libraries/Components/Subscribable.js @@ -25,7 +25,7 @@ var Subscribable = {}; Subscribable.Mixin = { - componentWillMount: function() { + UNSAFE_componentWillMount: function() { this._subscribableSubscriptions = []; }, diff --git a/Libraries/Components/TabBarIOS/TabBarItemIOS.ios.js b/Libraries/Components/TabBarIOS/TabBarItemIOS.ios.js index 215c4f27edbcda..d4e2687c198ff4 100644 --- a/Libraries/Components/TabBarIOS/TabBarItemIOS.ios.js +++ b/Libraries/Components/TabBarIOS/TabBarItemIOS.ios.js @@ -102,13 +102,13 @@ class TabBarItemIOS extends React.Component { hasBeenSelected: false, }; - componentWillMount() { + UNSAFE_componentWillMount() { if (this.props.selected) { this.setState({hasBeenSelected: true}); } } - componentWillReceiveProps(nextProps: { selected?: boolean }) { + UNSAFE_componentWillReceiveProps(nextProps: { selected?: boolean }) { if (this.state.hasBeenSelected || nextProps.selected) { this.setState({hasBeenSelected: true}); } diff --git a/Libraries/Components/Touchable/TouchableHighlight.js b/Libraries/Components/Touchable/TouchableHighlight.js index 02dc6bcc076e3b..04af3d17fff631 100644 --- a/Libraries/Components/Touchable/TouchableHighlight.js +++ b/Libraries/Components/Touchable/TouchableHighlight.js @@ -203,7 +203,7 @@ const TouchableHighlight = createReactClass({ clearTimeout(this._hideTimeout); }, - componentWillReceiveProps: function(nextProps) { + UNSAFE_componentWillReceiveProps: function(nextProps) { ensurePositiveDelayProps(nextProps); }, diff --git a/Libraries/Components/Touchable/TouchableNativeFeedback.android.js b/Libraries/Components/Touchable/TouchableNativeFeedback.android.js index 7436dd234278ee..f5e43340e04389 100644 --- a/Libraries/Components/Touchable/TouchableNativeFeedback.android.js +++ b/Libraries/Components/Touchable/TouchableNativeFeedback.android.js @@ -147,7 +147,7 @@ var TouchableNativeFeedback = createReactClass({ ensurePositiveDelayProps(this.props); }, - componentWillReceiveProps: function(nextProps) { + UNSAFE_componentWillReceiveProps: function(nextProps) { ensurePositiveDelayProps(nextProps); }, diff --git a/Libraries/Components/Touchable/TouchableOpacity.js b/Libraries/Components/Touchable/TouchableOpacity.js index 1dced65d627528..a27907ecef88be 100644 --- a/Libraries/Components/Touchable/TouchableOpacity.js +++ b/Libraries/Components/Touchable/TouchableOpacity.js @@ -158,7 +158,7 @@ var TouchableOpacity = createReactClass({ ensurePositiveDelayProps(this.props); }, - componentWillReceiveProps: function(nextProps) { + UNSAFE_componentWillReceiveProps: function(nextProps) { ensurePositiveDelayProps(nextProps); }, diff --git a/Libraries/Components/Touchable/TouchableWithoutFeedback.js b/Libraries/Components/Touchable/TouchableWithoutFeedback.js index d3ae834e2643a7..2a285dfa8013c6 100755 --- a/Libraries/Components/Touchable/TouchableWithoutFeedback.js +++ b/Libraries/Components/Touchable/TouchableWithoutFeedback.js @@ -122,7 +122,7 @@ const TouchableWithoutFeedback = createReactClass({ ensurePositiveDelayProps(this.props); }, - componentWillReceiveProps: function(nextProps: Object) { + UNSAFE_componentWillReceiveProps: function(nextProps: Object) { ensurePositiveDelayProps(nextProps); }, diff --git a/Libraries/Components/WebView/WebView.android.js b/Libraries/Components/WebView/WebView.android.js index 2f348510a5fd1a..07fb34309bf344 100644 --- a/Libraries/Components/WebView/WebView.android.js +++ b/Libraries/Components/WebView/WebView.android.js @@ -247,7 +247,7 @@ class WebView extends React.Component { startInLoadingState: true, }; - componentWillMount() { + UNSAFE_componentWillMount() { if (this.props.startInLoadingState) { this.setState({viewState: WebViewState.LOADING}); } diff --git a/Libraries/Components/WebView/WebView.ios.js b/Libraries/Components/WebView/WebView.ios.js index 33ca08cc684e9b..b68aecd1864f74 100644 --- a/Libraries/Components/WebView/WebView.ios.js +++ b/Libraries/Components/WebView/WebView.ios.js @@ -410,7 +410,7 @@ class WebView extends React.Component { startInLoadingState: true, }; - componentWillMount() { + UNSAFE_componentWillMount() { if (this.props.startInLoadingState) { this.setState({viewState: WebViewState.LOADING}); } diff --git a/Libraries/Experimental/Incremental.js b/Libraries/Experimental/Incremental.js index eb9d9a842190ad..c0d486eb021c31 100644 --- a/Libraries/Experimental/Incremental.js +++ b/Libraries/Experimental/Incremental.js @@ -129,7 +129,7 @@ class Incremental extends React.Component { return ctx.groupId + ':' + this._incrementId + '-' + this.props.name; } - componentWillMount() { + UNSAFE_componentWillMount() { const ctx = this.context.incrementalGroup; if (!ctx) { return; diff --git a/Libraries/Experimental/IncrementalGroup.js b/Libraries/Experimental/IncrementalGroup.js index c7200b69afb69c..81714929afe351 100644 --- a/Libraries/Experimental/IncrementalGroup.js +++ b/Libraries/Experimental/IncrementalGroup.js @@ -37,7 +37,7 @@ import type {Props, Context} from 'Incremental'; class IncrementalGroup extends React.Component { context: Context; _groupInc: string; - componentWillMount() { + UNSAFE_componentWillMount() { this._groupInc = `g${++_groupCounter}-`; DEBUG && infoLog( 'create IncrementalGroup with id ' + this.getGroupId() diff --git a/Libraries/Experimental/SwipeableRow/SwipeableListView.js b/Libraries/Experimental/SwipeableRow/SwipeableListView.js index 717e495f192363..1daf0a1e483c3e 100644 --- a/Libraries/Experimental/SwipeableRow/SwipeableListView.js +++ b/Libraries/Experimental/SwipeableRow/SwipeableListView.js @@ -105,7 +105,7 @@ class SwipeableListView extends React.Component { }; } - componentWillReceiveProps(nextProps: Props): void { + UNSAFE_componentWillReceiveProps(nextProps: Props): void { if (this.state.dataSource.getDataSource() !== nextProps.dataSource.getDataSource()) { this.setState({ dataSource: nextProps.dataSource, diff --git a/Libraries/Experimental/SwipeableRow/SwipeableRow.js b/Libraries/Experimental/SwipeableRow/SwipeableRow.js index db5763eaee0692..18c5bbd0eff93c 100644 --- a/Libraries/Experimental/SwipeableRow/SwipeableRow.js +++ b/Libraries/Experimental/SwipeableRow/SwipeableRow.js @@ -125,7 +125,7 @@ const SwipeableRow = createReactClass({ }; }, - componentWillMount(): void { + UNSAFE_componentWillMount(): void { this._panResponder = PanResponder.create({ onMoveShouldSetPanResponderCapture: this._handleMoveShouldSetPanResponderCapture, onPanResponderGrant: this._handlePanResponderGrant, @@ -149,7 +149,7 @@ const SwipeableRow = createReactClass({ } }, - componentWillReceiveProps(nextProps: Object): void { + UNSAFE_componentWillReceiveProps(nextProps: Object): void { /** * We do not need an "animateOpen(noCallback)" because this animation is * handled internally by this component. diff --git a/Libraries/Experimental/WindowedListView.js b/Libraries/Experimental/WindowedListView.js index 08bf44d6d13941..a457bea4ed3d2d 100644 --- a/Libraries/Experimental/WindowedListView.js +++ b/Libraries/Experimental/WindowedListView.js @@ -243,7 +243,7 @@ class WindowedListView extends React.Component { DEBUG && infoLog(' knope'); return false; } - componentWillReceiveProps() { + UNSAFE_componentWillReceiveProps() { this._computeRowsToRenderBatcher.schedule(); } _onMomentumScrollEnd = (e: Object) => { @@ -624,7 +624,7 @@ class CellRenderer extends React.Component { _perfUpdateID: number = 0; _asyncCookie: any; _includeInLayoutLatch: boolean = false; - componentWillMount() { + UNSAFE_componentWillMount() { if (this.props.asyncRowPerfEventName) { this._perfUpdateID = g_perf_update_id++; this._asyncCookie = Systrace.beginAsyncEvent( @@ -694,7 +694,7 @@ class CellRenderer extends React.Component { this.props.onProgressChange({rowKey: this.props.rowKey, inProgress: false}); this.props.onWillUnmount(this.props.rowKey); } - componentWillReceiveProps(newProps) { + UNSAFE_componentWillReceiveProps(newProps) { if (newProps.includeInLayout && !this.props.includeInLayout) { invariant(this._offscreenRenderDone, 'Should never try to add to layout before render done'); this._includeInLayoutLatch = true; // Once we render in layout, make sure it sticks. diff --git a/Libraries/Inspector/Inspector.js b/Libraries/Inspector/Inspector.js index 37eef369bb9459..3eb6682f2bd97c 100644 --- a/Libraries/Inspector/Inspector.js +++ b/Libraries/Inspector/Inspector.js @@ -92,7 +92,7 @@ class Inspector extends React.Component<{ hook.off('react-devtools', this.attachToDevtools); } - componentWillReceiveProps(newProps: Object) { + UNSAFE_componentWillReceiveProps(newProps: Object) { this.setState({inspectedViewTag: newProps.inspectedViewTag}); } diff --git a/Libraries/Lists/FlatList.js b/Libraries/Lists/FlatList.js index 7ac2bb07073d81..faf93d859c47d3 100644 --- a/Libraries/Lists/FlatList.js +++ b/Libraries/Lists/FlatList.js @@ -423,11 +423,11 @@ class FlatList extends React.PureComponent, void> { } } - componentWillMount() { + UNSAFE_componentWillMount() { this._checkProps(this.props); } - componentWillReceiveProps(nextProps: Props) { + UNSAFE_componentWillReceiveProps(nextProps: Props) { invariant( nextProps.numColumns === this.props.numColumns, 'Changing numColumns on the fly is not supported. Change the key prop on FlatList when ' + diff --git a/Libraries/Lists/ListView/ListView.js b/Libraries/Lists/ListView/ListView.js index 664ab27f0b356f..37c3f34cc21fc5 100644 --- a/Libraries/Lists/ListView/ListView.js +++ b/Libraries/Lists/ListView/ListView.js @@ -354,7 +354,7 @@ var ListView = createReactClass({ return this._scrollComponent.getInnerViewNode(); }, - componentWillMount: function() { + UNSAFE_componentWillMount: function() { // this data should never trigger a render pass, so don't put in state this.scrollProperties = { visibleLength: null, @@ -375,7 +375,7 @@ var ListView = createReactClass({ }); }, - componentWillReceiveProps: function(nextProps: Object) { + UNSAFE_componentWillReceiveProps: function(nextProps: Object) { if ( this.props.dataSource !== nextProps.dataSource || this.props.initialListSize !== nextProps.initialListSize diff --git a/Libraries/Lists/MetroListView.js b/Libraries/Lists/MetroListView.js index 339b5afc7c77e8..c839dc020ed346 100644 --- a/Libraries/Lists/MetroListView.js +++ b/Libraries/Lists/MetroListView.js @@ -135,7 +135,7 @@ class MetroListView extends React.Component { }), sectionHeaderData: {}, }); - componentWillReceiveProps(newProps: Props) { + UNSAFE_componentWillReceiveProps(newProps: Props) { this.setState(state => this._computeState(newProps, state)); } render() { diff --git a/Libraries/Lists/VirtualizedList.js b/Libraries/Lists/VirtualizedList.js index eb8b49025024b5..22fffa79cc2adf 100644 --- a/Libraries/Lists/VirtualizedList.js +++ b/Libraries/Lists/VirtualizedList.js @@ -611,7 +611,7 @@ class VirtualizedList extends React.PureComponent { this._fillRateHelper.deactivateAndFlush(); } - componentWillReceiveProps(newProps: Props) { + UNSAFE_componentWillReceiveProps(newProps: Props) { const {data, extraData, getItemCount, maxToRenderPerBatch} = newProps; // first and last could be stale (e.g. if a new, shorter items props is passed in), so we make // sure we're rendering a reasonable range here. diff --git a/Libraries/Lists/VirtualizedSectionList.js b/Libraries/Lists/VirtualizedSectionList.js index 7ac700107c7725..fbc83e2d153551 100644 --- a/Libraries/Lists/VirtualizedSectionList.js +++ b/Libraries/Lists/VirtualizedSectionList.js @@ -361,7 +361,7 @@ class VirtualizedSectionList extends React.PureComponent< this.state = this._computeState(props); } - componentWillReceiveProps(nextProps: Props) { + UNSAFE_componentWillReceiveProps(nextProps: Props) { this.setState(this._computeState(nextProps)); } @@ -446,7 +446,7 @@ class ItemWithSeparator extends React.Component< }, }; - componentWillReceiveProps(props: ItemWithSeparatorProps) { + UNSAFE_componentWillReceiveProps(props: ItemWithSeparatorProps) { this.setState(state => ({ separatorProps: { ...this.state.separatorProps, diff --git a/Libraries/Modal/Modal.js b/Libraries/Modal/Modal.js index 547ea07fec1d09..6d3c16a20a9738 100644 --- a/Libraries/Modal/Modal.js +++ b/Libraries/Modal/Modal.js @@ -151,7 +151,7 @@ class Modal extends React.Component { } } - componentWillReceiveProps(nextProps: Object) { + UNSAFE_componentWillReceiveProps(nextProps: Object) { Modal._confirmProps(nextProps); } diff --git a/RNTester/js/AnimatedGratuitousApp/AnExSet.js b/RNTester/js/AnimatedGratuitousApp/AnExSet.js index 7b2ba0f2adc1db..e3ea2acff32a46 100644 --- a/RNTester/js/AnimatedGratuitousApp/AnExSet.js +++ b/RNTester/js/AnimatedGratuitousApp/AnExSet.js @@ -75,7 +75,7 @@ class AnExSet extends React.Component { ); } - componentWillMount() { + UNSAFE_componentWillMount() { this.state.dismissY = new Animated.Value(0); this.state.dismissResponder = PanResponder.create({ onStartShouldSetPanResponder: () => this.props.isActive, diff --git a/RNTester/js/AnimatedGratuitousApp/AnExTilt.js b/RNTester/js/AnimatedGratuitousApp/AnExTilt.js index 293f910adc23eb..53e7c87e58dba2 100644 --- a/RNTester/js/AnimatedGratuitousApp/AnExTilt.js +++ b/RNTester/js/AnimatedGratuitousApp/AnExTilt.js @@ -77,7 +77,7 @@ class AnExTilt extends React.Component { }).start(); } - componentWillMount() { + UNSAFE_componentWillMount() { this._startBurnsZoom(); } diff --git a/RNTester/js/CameraRollView.js b/RNTester/js/CameraRollView.js index 3419989fb1262a..40d5606885620c 100644 --- a/RNTester/js/CameraRollView.js +++ b/RNTester/js/CameraRollView.js @@ -126,7 +126,7 @@ var CameraRollView = createReactClass({ this.fetch(); }, - componentWillReceiveProps: function(nextProps: {groupTypes?: string}) { + UNSAFE_componentWillReceiveProps: function(nextProps: {groupTypes?: string}) { if (this.props.groupTypes !== nextProps.groupTypes) { this.fetch(true); } diff --git a/RNTester/js/ImageExample.js b/RNTester/js/ImageExample.js index 7577b5b349cca1..1c56c3eab0b9f0 100644 --- a/RNTester/js/ImageExample.js +++ b/RNTester/js/ImageExample.js @@ -43,7 +43,7 @@ var NetworkImageCallbackExample = createReactClass({ }; }, - componentWillMount() { + UNSAFE_componentWillMount() { this.setState({mountTime: new Date()}); }, diff --git a/RNTester/js/LayoutAnimationExample.js b/RNTester/js/LayoutAnimationExample.js index 209ddbb610b8a1..58a2950eb3c095 100644 --- a/RNTester/js/LayoutAnimationExample.js +++ b/RNTester/js/LayoutAnimationExample.js @@ -26,7 +26,7 @@ class AddRemoveExample extends React.Component<{}, $FlowFixMeState> { views: [], }; - componentWillUpdate() { + UNSAFE_componentWillUpdate() { LayoutAnimation.easeInEaseOut(); } diff --git a/RNTester/js/ListViewExample.js b/RNTester/js/ListViewExample.js index 7007ed2035559c..7937739c7f2b63 100644 --- a/RNTester/js/ListViewExample.js +++ b/RNTester/js/ListViewExample.js @@ -41,7 +41,7 @@ var ListViewSimpleExample = createReactClass({ _pressData: ({}: {[key: number]: boolean}), - componentWillMount: function() { + UNSAFE_componentWillMount: function() { this._pressData = {}; }, diff --git a/RNTester/js/ListViewGridLayoutExample.js b/RNTester/js/ListViewGridLayoutExample.js index 455fbc2f340b82..8e31ebb3ea3d79 100644 --- a/RNTester/js/ListViewGridLayoutExample.js +++ b/RNTester/js/ListViewGridLayoutExample.js @@ -55,7 +55,7 @@ var ListViewGridLayoutExample = createReactClass({ _pressData: ({}: {[key: number]: boolean}), - componentWillMount: function() { + UNSAFE_componentWillMount: function() { this._pressData = {}; }, diff --git a/RNTester/js/ListViewPagingExample.js b/RNTester/js/ListViewPagingExample.js index 7d696c3b72ccf8..b247f167884c51 100644 --- a/RNTester/js/ListViewPagingExample.js +++ b/RNTester/js/ListViewPagingExample.js @@ -46,7 +46,7 @@ var NUM_SECTIONS = 100; var NUM_ROWS_PER_SECTION = 10; class Thumb extends React.Component<{}, $FlowFixMeState> { - componentWillMount() { + UNSAFE_componentWillMount() { UIManager.setLayoutAnimationEnabledExperimental && UIManager.setLayoutAnimationEnabledExperimental(true); } diff --git a/RNTester/js/PanResponderExample.js b/RNTester/js/PanResponderExample.js index a8d569338438aa..2acc3b594496c5 100644 --- a/RNTester/js/PanResponderExample.js +++ b/RNTester/js/PanResponderExample.js @@ -36,7 +36,7 @@ var PanResponderExample = createReactClass({ _circleStyles: {}, circle: (null : ?{ setNativeProps(props: Object): void }), - componentWillMount: function() { + UNSAFE_componentWillMount: function() { this._panResponder = PanResponder.create({ onStartShouldSetPanResponder: this._handleStartShouldSetPanResponder, onMoveShouldSetPanResponder: this._handleMoveShouldSetPanResponder, diff --git a/RNTester/js/PushNotificationIOSExample.js b/RNTester/js/PushNotificationIOSExample.js index 001d58719b6429..10b8f7700485fd 100644 --- a/RNTester/js/PushNotificationIOSExample.js +++ b/RNTester/js/PushNotificationIOSExample.js @@ -38,7 +38,7 @@ class Button extends React.Component<$FlowFixMeProps> { } class NotificationExample extends React.Component<{}> { - componentWillMount() { + UNSAFE_componentWillMount() { PushNotificationIOS.addEventListener('register', this._onRegistered); PushNotificationIOS.addEventListener('registrationError', this._onRegistrationError); PushNotificationIOS.addEventListener('notification', this._onRemoteNotification); diff --git a/RNTester/js/RNTesterApp.android.js b/RNTester/js/RNTesterApp.android.js index dad6b5cd71b854..b185191b4aafd4 100644 --- a/RNTester/js/RNTesterApp.android.js +++ b/RNTester/js/RNTesterApp.android.js @@ -57,7 +57,7 @@ const HEADER_NAV_ICON = nativeImageSource({ }); class RNTesterApp extends React.Component { - componentWillMount() { + UNSAFE_componentWillMount() { BackHandler.addEventListener('hardwareBackPress', this._handleBackButtonPress); } diff --git a/RNTester/js/RNTesterApp.ios.js b/RNTester/js/RNTesterApp.ios.js index 94bc1152a4c115..49feb6243f6355 100644 --- a/RNTester/js/RNTesterApp.ios.js +++ b/RNTester/js/RNTesterApp.ios.js @@ -57,7 +57,7 @@ const Header = ({ onBack, title }: { onBack?: () => mixed, title: string }) => ( ); class RNTesterApp extends React.Component { - componentWillMount() { + UNSAFE_componentWillMount() { BackHandler.addEventListener('hardwareBackPress', this._handleBack); } diff --git a/RNTester/js/RNTesterSettingSwitchRow.js b/RNTester/js/RNTesterSettingSwitchRow.js index 8ef45f4bf45ead..c252476f8d3cf1 100644 --- a/RNTester/js/RNTesterSettingSwitchRow.js +++ b/RNTester/js/RNTesterSettingSwitchRow.js @@ -19,7 +19,7 @@ const RNTesterStatePersister = require('./RNTesterStatePersister'); const View = require('View'); class RNTesterSettingSwitchRow extends React.Component<$FlowFixMeProps, $FlowFixMeState> { - componentWillReceiveProps(newProps) { + UNSAFE_componentWillReceiveProps(newProps) { const {onEnable, onDisable, persister} = this.props; if (newProps.persister.state !== persister.state) { newProps.persister.state ? onEnable() : onDisable(); diff --git a/RNTester/js/SwipeableListViewExample.js b/RNTester/js/SwipeableListViewExample.js index 6525933076323d..42e9c9c8947033 100644 --- a/RNTester/js/SwipeableListViewExample.js +++ b/RNTester/js/SwipeableListViewExample.js @@ -42,7 +42,7 @@ var SwipeableListViewSimpleExample = createReactClass({ _pressData: ({}: {[key: number]: boolean}), - componentWillMount: function() { + UNSAFE_componentWillMount: function() { this._pressData = {}; }, diff --git a/RNTester/js/TextInputExample.android.js b/RNTester/js/TextInputExample.android.js index e70d7d1ba50854..fa0d5986bad5d8 100644 --- a/RNTester/js/TextInputExample.android.js +++ b/RNTester/js/TextInputExample.android.js @@ -334,7 +334,7 @@ class AutogrowingTextInputExample extends React.Component<{}> { }; } - componentWillReceiveProps(props) { + UNSAFE_componentWillReceiveProps(props) { this.setState({ multiline: props.multiline, }); diff --git a/RNTester/js/TextInputExample.ios.js b/RNTester/js/TextInputExample.ios.js index 8266f067bc3316..cca082b92dc0ff 100644 --- a/RNTester/js/TextInputExample.ios.js +++ b/RNTester/js/TextInputExample.ios.js @@ -352,7 +352,7 @@ class AutogrowingTextInputExample extends React.Component<$FlowFixMeProps, $Flow }; } - componentWillReceiveProps(props) { + UNSAFE_componentWillReceiveProps(props) { this.setState({ multiline: props.multiline, }); diff --git a/ReactAndroid/src/androidTest/js/JSResponderTestApp.js b/ReactAndroid/src/androidTest/js/JSResponderTestApp.js index 9c88cedb27d614..2d9aedd911e421 100644 --- a/ReactAndroid/src/androidTest/js/JSResponderTestApp.js +++ b/ReactAndroid/src/androidTest/js/JSResponderTestApp.js @@ -22,7 +22,7 @@ class JSResponderTestApp extends React.Component { return Math.abs(gestureState.dx) > 30; }; - componentWillMount() { + UNSAFE_componentWillMount() { this.panGesture = PanResponder.create({ onMoveShouldSetPanResponder: this._handleMoveShouldSetPanResponder, }); diff --git a/ReactAndroid/src/androidTest/js/PickerAndroidTestModule.js b/ReactAndroid/src/androidTest/js/PickerAndroidTestModule.js index 219e3ec0a8ea36..faba7ec7de4094 100644 --- a/ReactAndroid/src/androidTest/js/PickerAndroidTestModule.js +++ b/ReactAndroid/src/androidTest/js/PickerAndroidTestModule.js @@ -28,7 +28,7 @@ class PickerAndroidTestApp extends React.Component { style: {}, }; - componentWillMount() { + UNSAFE_componentWillMount() { appInstance = this; } diff --git a/ReactAndroid/src/androidTest/js/SubviewsClippingTestModule.js b/ReactAndroid/src/androidTest/js/SubviewsClippingTestModule.js index 06fe1d3b70b073..4154e2a543bbe4 100644 --- a/ReactAndroid/src/androidTest/js/SubviewsClippingTestModule.js +++ b/ReactAndroid/src/androidTest/js/SubviewsClippingTestModule.js @@ -267,7 +267,7 @@ var appInstance = null; class SubviewsClippingTestApp extends React.Component { state = {}; - componentWillMount() { + UNSAFE_componentWillMount() { appInstance = this; } diff --git a/local-cli/templates/HelloNavigation/components/KeyboardSpacer.js b/local-cli/templates/HelloNavigation/components/KeyboardSpacer.js index 7324aded946ec5..f38567ea3ae206 100644 --- a/local-cli/templates/HelloNavigation/components/KeyboardSpacer.js +++ b/local-cli/templates/HelloNavigation/components/KeyboardSpacer.js @@ -1,3 +1,12 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + 'use strict'; /* @flow */ @@ -58,7 +67,7 @@ class KeyboardSpacerIOS extends Component { keyboardHeight: 0, }; - componentWillMount() { + UNSAFE_componentWillMount() { this._registerEvents(); } diff --git a/package.json b/package.json index 4ae9e8b33c6688..810ac61a1fb8c0 100644 --- a/package.json +++ b/package.json @@ -143,7 +143,7 @@ "react-native": "local-cli/wrong-react-native.js" }, "peerDependencies": { - "react": "16.2.0" + "react": "^16.3.0-alpha.0" }, "dependencies": { "absolute-path": "^0.0.0", @@ -219,8 +219,8 @@ "jest": "22.2.1", "jest-junit": "3.5.0", "prettier": "1.9.1", - "react": "16.2.0", - "react-test-renderer": "16.2.0", + "react": "^16.3.0-alpha.0", + "react-test-renderer": "^16.3.0-alpha.0", "shelljs": "^0.7.8", "sinon": "^2.2.0" }