Skip to content

Commit

Permalink
Ran rename-unsafe-lifecycles codemod on xplat/js
Browse files Browse the repository at this point in the history
Reviewed By: trueadm

Differential Revision: D6889214

fbshipit-source-id: e815cda4b09f3650ae3b0b9a44ae6f5fcb48fe25
  • Loading branch information
Brian Vaughn authored and facebook-github-bot committed Feb 8, 2018
1 parent fa334ce commit 6f007e8
Show file tree
Hide file tree
Showing 53 changed files with 75 additions and 66 deletions.
2 changes: 1 addition & 1 deletion IntegrationTests/ReactContentSizeUpdateTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var ReactContentSizeUpdateTest = createReactClass({
mixins: [Subscribable.Mixin,
TimerMixin],

componentWillMount: function() {
UNSAFE_componentWillMount: function() {
this.addListenerOn(
RCTNativeAppEventEmitter,
'rootViewDidChangeIntrinsicSize',
Expand Down
2 changes: 1 addition & 1 deletion IntegrationTests/SizeFlexibilityUpdateTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var SizeFlexibilityUpdateTest = createReactClass({
displayName: 'SizeFlexibilityUpdateTest',
mixins: [Subscribable.Mixin],

componentWillMount: function() {
UNSAFE_componentWillMount: function() {
this.addListenerOn(
RCTNativeAppEventEmitter,
'rootViewDidChangeIntrinsicSize',
Expand Down
6 changes: 3 additions & 3 deletions Libraries/Animated/src/__tests__/Animated-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand All @@ -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 = {};
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Animated/src/__tests__/AnimatedNative-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions Libraries/Animated/src/createAnimatedComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function createAnimatedComponent(Component: any): any {
this._component.setNativeProps(props);
}

componentWillMount() {
UNSAFE_componentWillMount() {
this._attachProps(this.props);
}

Expand Down Expand Up @@ -127,7 +127,7 @@ function createAnimatedComponent(Component: any): any {
oldPropsAnimated && oldPropsAnimated.__detach();
}

componentWillReceiveProps(newProps) {
UNSAFE_componentWillReceiveProps(newProps) {
this._attachProps(newProps);
}

Expand Down
4 changes: 2 additions & 2 deletions Libraries/Components/Keyboard/KeyboardAvoidingView.js
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand All @@ -143,7 +143,7 @@ const KeyboardAvoidingView = createReactClass({
}
},

componentWillMount() {
UNSAFE_componentWillMount() {
if (Platform.OS === 'ios') {
this.subscriptions = [
Keyboard.addListener('keyboardWillChangeFrame', this._onKeyboardChange),
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Components/LazyRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var LazyRenderer = createReactClass({
render: PropTypes.func.isRequired,
},

componentWillMount: function(): void {
UNSAFE_componentWillMount: function(): void {
this.setState({
_lazyRender : true,
});
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Components/Navigation/NavigatorIOS.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Components/Picker/PickerAndroid.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class PickerAndroid extends React.Component<{
};
}

componentWillReceiveProps(nextProps) {
UNSAFE_componentWillReceiveProps(nextProps) {
this.setState(this._stateFromProps(nextProps));
}

Expand Down
2 changes: 1 addition & 1 deletion Libraries/Components/Picker/PickerIOS.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ var PickerIOS = createReactClass({
return this._stateFromProps(this.props);
},

componentWillReceiveProps: function(nextProps) {
UNSAFE_componentWillReceiveProps: function(nextProps) {
this.setState(this._stateFromProps(nextProps));
},

Expand Down
2 changes: 1 addition & 1 deletion Libraries/Components/ScrollResponder.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Components/ScrollView/ScrollView.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Components/Subscribable.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var Subscribable = {};

Subscribable.Mixin = {

componentWillMount: function() {
UNSAFE_componentWillMount: function() {
this._subscribableSubscriptions = [];
},

Expand Down
4 changes: 2 additions & 2 deletions Libraries/Components/TabBarIOS/TabBarItemIOS.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -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});
}
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Components/Touchable/TouchableHighlight.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ const TouchableHighlight = createReactClass({
clearTimeout(this._hideTimeout);
},

componentWillReceiveProps: function(nextProps) {
UNSAFE_componentWillReceiveProps: function(nextProps) {
ensurePositiveDelayProps(nextProps);
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ var TouchableNativeFeedback = createReactClass({
ensurePositiveDelayProps(this.props);
},

componentWillReceiveProps: function(nextProps) {
UNSAFE_componentWillReceiveProps: function(nextProps) {
ensurePositiveDelayProps(nextProps);
},

Expand Down
2 changes: 1 addition & 1 deletion Libraries/Components/Touchable/TouchableOpacity.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ var TouchableOpacity = createReactClass({
ensurePositiveDelayProps(this.props);
},

componentWillReceiveProps: function(nextProps) {
UNSAFE_componentWillReceiveProps: function(nextProps) {
ensurePositiveDelayProps(nextProps);
},

Expand Down
2 changes: 1 addition & 1 deletion Libraries/Components/Touchable/TouchableWithoutFeedback.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ const TouchableWithoutFeedback = createReactClass({
ensurePositiveDelayProps(this.props);
},

componentWillReceiveProps: function(nextProps: Object) {
UNSAFE_componentWillReceiveProps: function(nextProps: Object) {
ensurePositiveDelayProps(nextProps);
},

Expand Down
2 changes: 1 addition & 1 deletion Libraries/Components/WebView/WebView.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ class WebView extends React.Component {
startInLoadingState: true,
};

componentWillMount() {
UNSAFE_componentWillMount() {
if (this.props.startInLoadingState) {
this.setState({viewState: WebViewState.LOADING});
}
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Components/WebView/WebView.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ class WebView extends React.Component {
startInLoadingState: true,
};

componentWillMount() {
UNSAFE_componentWillMount() {
if (this.props.startInLoadingState) {
this.setState({viewState: WebViewState.LOADING});
}
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Experimental/Incremental.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class Incremental extends React.Component<Props, State> {
return ctx.groupId + ':' + this._incrementId + '-' + this.props.name;
}

componentWillMount() {
UNSAFE_componentWillMount() {
const ctx = this.context.incrementalGroup;
if (!ctx) {
return;
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Experimental/IncrementalGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import type {Props, Context} from 'Incremental';
class IncrementalGroup extends React.Component<Props & {disabled?: boolean}> {
context: Context;
_groupInc: string;
componentWillMount() {
UNSAFE_componentWillMount() {
this._groupInc = `g${++_groupCounter}-`;
DEBUG && infoLog(
'create IncrementalGroup with id ' + this.getGroupId()
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Experimental/SwipeableRow/SwipeableListView.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class SwipeableListView extends React.Component<Props, State> {
};
}

componentWillReceiveProps(nextProps: Props): void {
UNSAFE_componentWillReceiveProps(nextProps: Props): void {
if (this.state.dataSource.getDataSource() !== nextProps.dataSource.getDataSource()) {
this.setState({
dataSource: nextProps.dataSource,
Expand Down
4 changes: 2 additions & 2 deletions Libraries/Experimental/SwipeableRow/SwipeableRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ const SwipeableRow = createReactClass({
};
},

componentWillMount(): void {
UNSAFE_componentWillMount(): void {
this._panResponder = PanResponder.create({
onMoveShouldSetPanResponderCapture: this._handleMoveShouldSetPanResponderCapture,
onPanResponderGrant: this._handlePanResponderGrant,
Expand All @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions Libraries/Experimental/WindowedListView.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ class WindowedListView extends React.Component<Props, State> {
DEBUG && infoLog(' knope');
return false;
}
componentWillReceiveProps() {
UNSAFE_componentWillReceiveProps() {
this._computeRowsToRenderBatcher.schedule();
}
_onMomentumScrollEnd = (e: Object) => {
Expand Down Expand Up @@ -624,7 +624,7 @@ class CellRenderer extends React.Component<CellProps> {
_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(
Expand Down Expand Up @@ -694,7 +694,7 @@ class CellRenderer extends React.Component<CellProps> {
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.
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Inspector/Inspector.js
Original file line number Diff line number Diff line change
Expand Up @@ -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});
}

Expand Down
4 changes: 2 additions & 2 deletions Libraries/Lists/FlatList.js
Original file line number Diff line number Diff line change
Expand Up @@ -423,11 +423,11 @@ class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
}
}

componentWillMount() {
UNSAFE_componentWillMount() {
this._checkProps(this.props);
}

componentWillReceiveProps(nextProps: Props<ItemT>) {
UNSAFE_componentWillReceiveProps(nextProps: Props<ItemT>) {
invariant(
nextProps.numColumns === this.props.numColumns,
'Changing numColumns on the fly is not supported. Change the key prop on FlatList when ' +
Expand Down
4 changes: 2 additions & 2 deletions Libraries/Lists/ListView/ListView.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Lists/MetroListView.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class MetroListView extends React.Component<Props, $FlowFixMeState> {
}),
sectionHeaderData: {},
});
componentWillReceiveProps(newProps: Props) {
UNSAFE_componentWillReceiveProps(newProps: Props) {
this.setState(state => this._computeState(newProps, state));
}
render() {
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Lists/VirtualizedList.js
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
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.
Expand Down
4 changes: 2 additions & 2 deletions Libraries/Lists/VirtualizedSectionList.js
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ class VirtualizedSectionList<SectionT: SectionBase> extends React.PureComponent<
this.state = this._computeState(props);
}

componentWillReceiveProps(nextProps: Props<SectionT>) {
UNSAFE_componentWillReceiveProps(nextProps: Props<SectionT>) {
this.setState(this._computeState(nextProps));
}

Expand Down Expand Up @@ -446,7 +446,7 @@ class ItemWithSeparator extends React.Component<
},
};

componentWillReceiveProps(props: ItemWithSeparatorProps) {
UNSAFE_componentWillReceiveProps(props: ItemWithSeparatorProps) {
this.setState(state => ({
separatorProps: {
...this.state.separatorProps,
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Modal/Modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class Modal extends React.Component<Object> {
}
}

componentWillReceiveProps(nextProps: Object) {
UNSAFE_componentWillReceiveProps(nextProps: Object) {
Modal._confirmProps(nextProps);
}

Expand Down
2 changes: 1 addition & 1 deletion RNTester/js/AnimatedGratuitousApp/AnExSet.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class AnExSet extends React.Component<Object, any> {
);
}

componentWillMount() {
UNSAFE_componentWillMount() {
this.state.dismissY = new Animated.Value(0);
this.state.dismissResponder = PanResponder.create({
onStartShouldSetPanResponder: () => this.props.isActive,
Expand Down
2 changes: 1 addition & 1 deletion RNTester/js/AnimatedGratuitousApp/AnExTilt.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class AnExTilt extends React.Component<Object, any> {
}).start();
}

componentWillMount() {
UNSAFE_componentWillMount() {
this._startBurnsZoom();
}

Expand Down
Loading

0 comments on commit 6f007e8

Please sign in to comment.