Skip to content

Commit 28a0e4b

Browse files
committed
Ran lifecycle hook codemod over project
This should handle the bulk of the updates. I will manually update TypeScript and CoffeeScript tests with another commit. The actual command run with this commit was: jscodeshift --parser=flow -t ../react-codemod/transforms/rename-unsafe-lifecycles.js ./packages/**/src/**/*.js
1 parent e709e30 commit 28a0e4b

20 files changed

+139
-139
lines changed

packages/react-call-return/src/__tests__/ReactCallReturn-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ describe('ReactCallReturn', () => {
275275
return ReactCallReturn.unstable_createReturn(this.props.children);
276276
}
277277

278-
componentWillMount() {
278+
unsafe_componentWillMount() {
279279
ops.push(`Mount Return ${this.props.value}`);
280280
}
281281

packages/react-dom/src/__tests__/ReactComponentLifeCycle-test.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ describe('ReactComponentLifeCycle', () => {
165165
// had provided a getInitialState method.
166166
it('throws when accessing state in componentWillMount', () => {
167167
class StatefulComponent extends React.Component {
168-
componentWillMount() {
168+
unsafe_componentWillMount() {
169169
void this.state.yada;
170170
}
171171

@@ -182,7 +182,7 @@ describe('ReactComponentLifeCycle', () => {
182182

183183
it('should allow update state inside of componentWillMount', () => {
184184
class StatefulComponent extends React.Component {
185-
componentWillMount() {
185+
unsafe_componentWillMount() {
186186
this.setState({stateField: 'something'});
187187
}
188188

@@ -231,7 +231,7 @@ describe('ReactComponentLifeCycle', () => {
231231
// reaching into the updater.
232232
return this.updater.isMounted(this);
233233
}
234-
componentWillMount() {
234+
unsafe_componentWillMount() {
235235
expect(this._isMounted()).toBeFalsy();
236236
}
237237
componentDidMount() {
@@ -258,7 +258,7 @@ describe('ReactComponentLifeCycle', () => {
258258
// reaching into the updater.
259259
return this.updater.isMounted(this);
260260
}
261-
componentWillMount() {
261+
unsafe_componentWillMount() {
262262
expect(this._isMounted()).toBeFalsy();
263263
}
264264
componentDidMount() {
@@ -334,7 +334,7 @@ describe('ReactComponentLifeCycle', () => {
334334
this.state = initState;
335335
}
336336

337-
componentWillMount() {
337+
unsafe_componentWillMount() {
338338
this._testJournal.stateAtStartOfWillMount = clone(this.state);
339339
this._testJournal.lifeCycleAtStartOfWillMount = getLifeCycleState(this);
340340
this.state.hasWillMountCompleted = true;
@@ -509,11 +509,11 @@ describe('ReactComponentLifeCycle', () => {
509509
};
510510
};
511511
class Outer extends React.Component {
512-
componentWillMount = logger('outer componentWillMount');
512+
unsafe_componentWillMount = logger('outer componentWillMount');
513513
componentDidMount = logger('outer componentDidMount');
514-
componentWillReceiveProps = logger('outer componentWillReceiveProps');
514+
unsafe_componentWillReceiveProps = logger('outer componentWillReceiveProps');
515515
shouldComponentUpdate = logger('outer shouldComponentUpdate');
516-
componentWillUpdate = logger('outer componentWillUpdate');
516+
unsafe_componentWillUpdate = logger('outer componentWillUpdate');
517517
componentDidUpdate = logger('outer componentDidUpdate');
518518
componentWillUnmount = logger('outer componentWillUnmount');
519519
render() {
@@ -526,11 +526,11 @@ describe('ReactComponentLifeCycle', () => {
526526
}
527527

528528
class Inner extends React.Component {
529-
componentWillMount = logger('inner componentWillMount');
529+
unsafe_componentWillMount = logger('inner componentWillMount');
530530
componentDidMount = logger('inner componentDidMount');
531-
componentWillReceiveProps = logger('inner componentWillReceiveProps');
531+
unsafe_componentWillReceiveProps = logger('inner componentWillReceiveProps');
532532
shouldComponentUpdate = logger('inner shouldComponentUpdate');
533-
componentWillUpdate = logger('inner componentWillUpdate');
533+
unsafe_componentWillUpdate = logger('inner componentWillUpdate');
534534
componentDidUpdate = logger('inner componentDidUpdate');
535535
componentWillUnmount = logger('inner componentWillUnmount');
536536
render() {
@@ -579,7 +579,7 @@ describe('ReactComponentLifeCycle', () => {
579579
log.push('render');
580580
return <Child />;
581581
},
582-
componentWillMount() {
582+
unsafe_componentWillMount() {
583583
log.push('will mount');
584584
},
585585
componentDidMount() {

packages/react-dom/src/__tests__/ReactCompositeComponent-test.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,7 @@ describe('ReactCompositeComponent', () => {
850850
foo: PropTypes.string.isRequired,
851851
};
852852

853-
componentWillReceiveProps(nextProps, nextContext) {
853+
unsafe_componentWillReceiveProps(nextProps, nextContext) {
854854
expect('foo' in nextContext).toBe(true);
855855
}
856856

@@ -865,7 +865,7 @@ describe('ReactCompositeComponent', () => {
865865
}
866866

867867
class Intermediary extends React.Component {
868-
componentWillReceiveProps(nextProps, nextContext) {
868+
unsafe_componentWillReceiveProps(nextProps, nextContext) {
869869
expect('foo' in nextContext).toBe(false);
870870
}
871871

@@ -916,7 +916,7 @@ describe('ReactCompositeComponent', () => {
916916
foo: PropTypes.string.isRequired,
917917
};
918918

919-
componentWillReceiveProps(nextProps, nextContext) {
919+
unsafe_componentWillReceiveProps(nextProps, nextContext) {
920920
expect('foo' in nextContext).toBe(true);
921921

922922
if (nextProps !== this.props) {
@@ -938,7 +938,7 @@ describe('ReactCompositeComponent', () => {
938938
foo: PropTypes.string.isRequired,
939939
};
940940

941-
componentWillReceiveProps(nextProps, nextContext) {
941+
unsafe_componentWillReceiveProps(nextProps, nextContext) {
942942
expect('foo' in nextContext).toBe(true);
943943

944944
if (nextProps !== this.props) {
@@ -956,7 +956,7 @@ describe('ReactCompositeComponent', () => {
956956
}
957957

958958
class ChildWithoutContext extends React.Component {
959-
componentWillReceiveProps(nextProps, nextContext) {
959+
unsafe_componentWillReceiveProps(nextProps, nextContext) {
960960
expect('foo' in nextContext).toBe(false);
961961

962962
if (nextProps !== this.props) {
@@ -1047,7 +1047,7 @@ describe('ReactCompositeComponent', () => {
10471047
class Component extends React.Component {
10481048
state = {updated: false};
10491049

1050-
componentWillReceiveProps(props) {
1050+
unsafe_componentWillReceiveProps(props) {
10511051
expect(props.update).toBe(1);
10521052
expect(renders).toBe(1);
10531053
this.setState({updated: true});
@@ -1075,7 +1075,7 @@ describe('ReactCompositeComponent', () => {
10751075
class Component extends React.Component {
10761076
state = {updated: false};
10771077

1078-
componentWillReceiveProps(props) {
1078+
unsafe_componentWillReceiveProps(props) {
10791079
expect(props.update).toBe(1);
10801080
expect(renders).toBe(1);
10811081
this.setState({updated: true});
@@ -1377,7 +1377,7 @@ describe('ReactCompositeComponent', () => {
13771377
const log = [];
13781378

13791379
class Spy extends React.Component {
1380-
componentWillMount() {
1380+
unsafe_componentWillMount() {
13811381
log.push(this.props.name + ' componentWillMount');
13821382
}
13831383
render() {
@@ -1556,7 +1556,7 @@ describe('ReactCompositeComponent', () => {
15561556
};
15571557
}
15581558

1559-
componentWillMount() {
1559+
unsafe_componentWillMount() {
15601560
this.setState(
15611561
{hasUpdatedState: true},
15621562
() => (stateSuccessfullyUpdated = this.state.hasUpdatedState),
@@ -1586,7 +1586,7 @@ describe('ReactCompositeComponent', () => {
15861586
};
15871587
}
15881588

1589-
componentWillMount() {
1589+
unsafe_componentWillMount() {
15901590
instance = this;
15911591
}
15921592

packages/react-dom/src/__tests__/ReactCompositeComponentState-test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ describe('ReactCompositeComponent-state', () => {
4646
return <div>{this.state.color}</div>;
4747
}
4848

49-
componentWillMount() {
49+
unsafe_componentWillMount() {
5050
this.peekAtState('componentWillMount-start');
5151
this.setState(function(state) {
5252
this.peekAtState('before-setState-sunrise', state);
@@ -78,7 +78,7 @@ describe('ReactCompositeComponent-state', () => {
7878
this.peekAtState('componentDidMount-end');
7979
}
8080

81-
componentWillReceiveProps(newProps) {
81+
unsafe_componentWillReceiveProps(newProps) {
8282
this.peekAtState('componentWillReceiveProps-start');
8383
if (newProps.nextColor) {
8484
this.setState(function(state) {
@@ -105,7 +105,7 @@ describe('ReactCompositeComponent-state', () => {
105105
return true;
106106
}
107107

108-
componentWillUpdate(nextProps, nextState) {
108+
unsafe_componentWillUpdate(nextProps, nextState) {
109109
this.peekAtState('componentWillUpdate-currentState');
110110
this.peekAtState('componentWillUpdate-nextState', nextState);
111111
}
@@ -323,7 +323,7 @@ describe('ReactCompositeComponent-state', () => {
323323
}
324324
let updated = false;
325325
class Child extends React.Component {
326-
componentWillReceiveProps() {
326+
unsafe_componentWillReceiveProps() {
327327
if (updated) {
328328
return;
329329
}
@@ -383,7 +383,7 @@ describe('ReactCompositeComponent-state', () => {
383383
let ops = [];
384384
class Test extends React.Component {
385385
state = {step: 1, extra: true};
386-
componentWillReceiveProps() {
386+
unsafe_componentWillReceiveProps() {
387387
this.setState({step: 2}, () => {
388388
// Tests that earlier setState callbacks are not dropped
389389
ops.push(
@@ -426,7 +426,7 @@ describe('ReactCompositeComponent-state', () => {
426426
let ops = [];
427427
class Test extends React.Component {
428428
state = {step: 1, extra: true};
429-
componentWillMount() {
429+
unsafe_componentWillMount() {
430430
this.setState({step: 2}, () => {
431431
// Tests that earlier setState callbacks are not dropped
432432
ops.push(

packages/react-dom/src/__tests__/ReactDOMServerIntegrationContext-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ describe('ReactDOMServerIntegration', () => {
231231
getChildContext() {
232232
return {text: this.state.text};
233233
}
234-
componentWillMount() {
234+
unsafe_componentWillMount() {
235235
this.setState({text: 'foo'});
236236
}
237237
render() {

0 commit comments

Comments
 (0)