Skip to content

Commit

Permalink
Ran lifecycle hook codemod over project
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bvaughn committed Jan 16, 2018
1 parent e709e30 commit 28a0e4b
Show file tree
Hide file tree
Showing 20 changed files with 139 additions and 139 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ describe('ReactCallReturn', () => {
return ReactCallReturn.unstable_createReturn(this.props.children);
}

componentWillMount() {
unsafe_componentWillMount() {
ops.push(`Mount Return ${this.props.value}`);
}

Expand Down
24 changes: 12 additions & 12 deletions packages/react-dom/src/__tests__/ReactComponentLifeCycle-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ describe('ReactComponentLifeCycle', () => {
// had provided a getInitialState method.
it('throws when accessing state in componentWillMount', () => {
class StatefulComponent extends React.Component {
componentWillMount() {
unsafe_componentWillMount() {
void this.state.yada;
}

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

it('should allow update state inside of componentWillMount', () => {
class StatefulComponent extends React.Component {
componentWillMount() {
unsafe_componentWillMount() {
this.setState({stateField: 'something'});
}

Expand Down Expand Up @@ -231,7 +231,7 @@ describe('ReactComponentLifeCycle', () => {
// reaching into the updater.
return this.updater.isMounted(this);
}
componentWillMount() {
unsafe_componentWillMount() {
expect(this._isMounted()).toBeFalsy();
}
componentDidMount() {
Expand All @@ -258,7 +258,7 @@ describe('ReactComponentLifeCycle', () => {
// reaching into the updater.
return this.updater.isMounted(this);
}
componentWillMount() {
unsafe_componentWillMount() {
expect(this._isMounted()).toBeFalsy();
}
componentDidMount() {
Expand Down Expand Up @@ -334,7 +334,7 @@ describe('ReactComponentLifeCycle', () => {
this.state = initState;
}

componentWillMount() {
unsafe_componentWillMount() {
this._testJournal.stateAtStartOfWillMount = clone(this.state);
this._testJournal.lifeCycleAtStartOfWillMount = getLifeCycleState(this);
this.state.hasWillMountCompleted = true;
Expand Down Expand Up @@ -509,11 +509,11 @@ describe('ReactComponentLifeCycle', () => {
};
};
class Outer extends React.Component {
componentWillMount = logger('outer componentWillMount');
unsafe_componentWillMount = logger('outer componentWillMount');
componentDidMount = logger('outer componentDidMount');
componentWillReceiveProps = logger('outer componentWillReceiveProps');
unsafe_componentWillReceiveProps = logger('outer componentWillReceiveProps');
shouldComponentUpdate = logger('outer shouldComponentUpdate');
componentWillUpdate = logger('outer componentWillUpdate');
unsafe_componentWillUpdate = logger('outer componentWillUpdate');
componentDidUpdate = logger('outer componentDidUpdate');
componentWillUnmount = logger('outer componentWillUnmount');
render() {
Expand All @@ -526,11 +526,11 @@ describe('ReactComponentLifeCycle', () => {
}

class Inner extends React.Component {
componentWillMount = logger('inner componentWillMount');
unsafe_componentWillMount = logger('inner componentWillMount');
componentDidMount = logger('inner componentDidMount');
componentWillReceiveProps = logger('inner componentWillReceiveProps');
unsafe_componentWillReceiveProps = logger('inner componentWillReceiveProps');
shouldComponentUpdate = logger('inner shouldComponentUpdate');
componentWillUpdate = logger('inner componentWillUpdate');
unsafe_componentWillUpdate = logger('inner componentWillUpdate');
componentDidUpdate = logger('inner componentDidUpdate');
componentWillUnmount = logger('inner componentWillUnmount');
render() {
Expand Down Expand Up @@ -579,7 +579,7 @@ describe('ReactComponentLifeCycle', () => {
log.push('render');
return <Child />;
},
componentWillMount() {
unsafe_componentWillMount() {
log.push('will mount');
},
componentDidMount() {
Expand Down
20 changes: 10 additions & 10 deletions packages/react-dom/src/__tests__/ReactCompositeComponent-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ describe('ReactCompositeComponent', () => {
foo: PropTypes.string.isRequired,
};

componentWillReceiveProps(nextProps, nextContext) {
unsafe_componentWillReceiveProps(nextProps, nextContext) {
expect('foo' in nextContext).toBe(true);
}

Expand All @@ -865,7 +865,7 @@ describe('ReactCompositeComponent', () => {
}

class Intermediary extends React.Component {
componentWillReceiveProps(nextProps, nextContext) {
unsafe_componentWillReceiveProps(nextProps, nextContext) {
expect('foo' in nextContext).toBe(false);
}

Expand Down Expand Up @@ -916,7 +916,7 @@ describe('ReactCompositeComponent', () => {
foo: PropTypes.string.isRequired,
};

componentWillReceiveProps(nextProps, nextContext) {
unsafe_componentWillReceiveProps(nextProps, nextContext) {
expect('foo' in nextContext).toBe(true);

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

componentWillReceiveProps(nextProps, nextContext) {
unsafe_componentWillReceiveProps(nextProps, nextContext) {
expect('foo' in nextContext).toBe(true);

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

class ChildWithoutContext extends React.Component {
componentWillReceiveProps(nextProps, nextContext) {
unsafe_componentWillReceiveProps(nextProps, nextContext) {
expect('foo' in nextContext).toBe(false);

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

componentWillReceiveProps(props) {
unsafe_componentWillReceiveProps(props) {
expect(props.update).toBe(1);
expect(renders).toBe(1);
this.setState({updated: true});
Expand Down Expand Up @@ -1075,7 +1075,7 @@ describe('ReactCompositeComponent', () => {
class Component extends React.Component {
state = {updated: false};

componentWillReceiveProps(props) {
unsafe_componentWillReceiveProps(props) {
expect(props.update).toBe(1);
expect(renders).toBe(1);
this.setState({updated: true});
Expand Down Expand Up @@ -1377,7 +1377,7 @@ describe('ReactCompositeComponent', () => {
const log = [];

class Spy extends React.Component {
componentWillMount() {
unsafe_componentWillMount() {
log.push(this.props.name + ' componentWillMount');
}
render() {
Expand Down Expand Up @@ -1556,7 +1556,7 @@ describe('ReactCompositeComponent', () => {
};
}

componentWillMount() {
unsafe_componentWillMount() {
this.setState(
{hasUpdatedState: true},
() => (stateSuccessfullyUpdated = this.state.hasUpdatedState),
Expand Down Expand Up @@ -1586,7 +1586,7 @@ describe('ReactCompositeComponent', () => {
};
}

componentWillMount() {
unsafe_componentWillMount() {
instance = this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe('ReactCompositeComponent-state', () => {
return <div>{this.state.color}</div>;
}

componentWillMount() {
unsafe_componentWillMount() {
this.peekAtState('componentWillMount-start');
this.setState(function(state) {
this.peekAtState('before-setState-sunrise', state);
Expand Down Expand Up @@ -78,7 +78,7 @@ describe('ReactCompositeComponent-state', () => {
this.peekAtState('componentDidMount-end');
}

componentWillReceiveProps(newProps) {
unsafe_componentWillReceiveProps(newProps) {
this.peekAtState('componentWillReceiveProps-start');
if (newProps.nextColor) {
this.setState(function(state) {
Expand All @@ -105,7 +105,7 @@ describe('ReactCompositeComponent-state', () => {
return true;
}

componentWillUpdate(nextProps, nextState) {
unsafe_componentWillUpdate(nextProps, nextState) {
this.peekAtState('componentWillUpdate-currentState');
this.peekAtState('componentWillUpdate-nextState', nextState);
}
Expand Down Expand Up @@ -323,7 +323,7 @@ describe('ReactCompositeComponent-state', () => {
}
let updated = false;
class Child extends React.Component {
componentWillReceiveProps() {
unsafe_componentWillReceiveProps() {
if (updated) {
return;
}
Expand Down Expand Up @@ -383,7 +383,7 @@ describe('ReactCompositeComponent-state', () => {
let ops = [];
class Test extends React.Component {
state = {step: 1, extra: true};
componentWillReceiveProps() {
unsafe_componentWillReceiveProps() {
this.setState({step: 2}, () => {
// Tests that earlier setState callbacks are not dropped
ops.push(
Expand Down Expand Up @@ -426,7 +426,7 @@ describe('ReactCompositeComponent-state', () => {
let ops = [];
class Test extends React.Component {
state = {step: 1, extra: true};
componentWillMount() {
unsafe_componentWillMount() {
this.setState({step: 2}, () => {
// Tests that earlier setState callbacks are not dropped
ops.push(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ describe('ReactDOMServerIntegration', () => {
getChildContext() {
return {text: this.state.text};
}
componentWillMount() {
unsafe_componentWillMount() {
this.setState({text: 'foo'});
}
render() {
Expand Down
Loading

0 comments on commit 28a0e4b

Please sign in to comment.