Skip to content

Commit

Permalink
Renamed unsafe_* prefix to UNSAFE_* to be more noticeable
Browse files Browse the repository at this point in the history
  • Loading branch information
bvaughn committed Jan 17, 2018
1 parent 035c220 commit 8d0e001
Show file tree
Hide file tree
Showing 28 changed files with 197 additions and 185 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);
}

unsafe_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 {
unsafe_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 {
unsafe_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);
}
unsafe_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);
}
unsafe_componentWillMount() {
UNSAFE_componentWillMount() {
expect(this._isMounted()).toBeFalsy();
}
componentDidMount() {
Expand Down Expand Up @@ -334,7 +334,7 @@ describe('ReactComponentLifeCycle', () => {
this.state = initState;
}

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

class Inner extends React.Component {
unsafe_componentWillMount = logger('inner componentWillMount');
UNSAFE_componentWillMount = logger('inner componentWillMount');
componentDidMount = logger('inner componentDidMount');
unsafe_componentWillReceiveProps = logger(
UNSAFE_componentWillReceiveProps = logger(
'inner componentWillReceiveProps',
);
shouldComponentUpdate = logger('inner shouldComponentUpdate');
unsafe_componentWillUpdate = logger('inner componentWillUpdate');
UNSAFE_componentWillUpdate = logger('inner componentWillUpdate');
componentDidUpdate = logger('inner componentDidUpdate');
componentWillUnmount = logger('inner componentWillUnmount');
render() {
Expand Down Expand Up @@ -583,7 +583,7 @@ describe('ReactComponentLifeCycle', () => {
log.push('render');
return <Child />;
},
unsafe_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,
};

unsafe_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 {
unsafe_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,
};

unsafe_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,
};

unsafe_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 {
unsafe_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};

unsafe_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};

unsafe_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 {
unsafe_componentWillMount() {
UNSAFE_componentWillMount() {
log.push(this.props.name + ' componentWillMount');
}
render() {
Expand Down Expand Up @@ -1556,7 +1556,7 @@ describe('ReactCompositeComponent', () => {
};
}

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

unsafe_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>;
}

unsafe_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');
}

unsafe_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;
}

unsafe_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 {
unsafe_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};
unsafe_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};
unsafe_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};
}
unsafe_componentWillMount() {
UNSAFE_componentWillMount() {
this.setState({text: 'foo'});
}
render() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('ReactDOMServerLifecycles', () => {
const log = [];

class Outer extends React.Component {
unsafe_componentWillMount() {
UNSAFE_componentWillMount() {
log.push('outer componentWillMount');
}
render() {
Expand All @@ -47,7 +47,7 @@ describe('ReactDOMServerLifecycles', () => {
}

class Inner extends React.Component {
unsafe_componentWillMount() {
UNSAFE_componentWillMount() {
log.push('inner componentWillMount');
}
render() {
Expand Down Expand Up @@ -75,7 +75,7 @@ describe('ReactDOMServerLifecycles', () => {

expect(() => ReactDOMServer.renderToString(<Component />)).toWarnDev(
'Warning: Component: componentWillMount() is deprecated and will be removed ' +
'in the next major version. Please use unsafe_componentWillMount() instead.',
'in the next major version. Please use UNSAFE_componentWillMount() instead.',
);

// De-duped
Expand Down
Loading

0 comments on commit 8d0e001

Please sign in to comment.