Skip to content

Commit 8d0e001

Browse files
committed
Renamed unsafe_* prefix to UNSAFE_* to be more noticeable
1 parent 035c220 commit 8d0e001

28 files changed

+197
-185
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-
unsafe_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-
unsafe_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-
unsafe_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-
unsafe_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-
unsafe_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-
unsafe_componentWillMount() {
337+
UNSAFE_componentWillMount() {
338338
this._testJournal.stateAtStartOfWillMount = clone(this.state);
339339
this._testJournal.lifeCycleAtStartOfWillMount = getLifeCycleState(this);
340340
this.state.hasWillMountCompleted = true;
@@ -509,13 +509,13 @@ describe('ReactComponentLifeCycle', () => {
509509
};
510510
};
511511
class Outer extends React.Component {
512-
unsafe_componentWillMount = logger('outer componentWillMount');
512+
UNSAFE_componentWillMount = logger('outer componentWillMount');
513513
componentDidMount = logger('outer componentDidMount');
514-
unsafe_componentWillReceiveProps = logger(
514+
UNSAFE_componentWillReceiveProps = logger(
515515
'outer componentWillReceiveProps',
516516
);
517517
shouldComponentUpdate = logger('outer shouldComponentUpdate');
518-
unsafe_componentWillUpdate = logger('outer componentWillUpdate');
518+
UNSAFE_componentWillUpdate = logger('outer componentWillUpdate');
519519
componentDidUpdate = logger('outer componentDidUpdate');
520520
componentWillUnmount = logger('outer componentWillUnmount');
521521
render() {
@@ -528,13 +528,13 @@ describe('ReactComponentLifeCycle', () => {
528528
}
529529

530530
class Inner extends React.Component {
531-
unsafe_componentWillMount = logger('inner componentWillMount');
531+
UNSAFE_componentWillMount = logger('inner componentWillMount');
532532
componentDidMount = logger('inner componentDidMount');
533-
unsafe_componentWillReceiveProps = logger(
533+
UNSAFE_componentWillReceiveProps = logger(
534534
'inner componentWillReceiveProps',
535535
);
536536
shouldComponentUpdate = logger('inner shouldComponentUpdate');
537-
unsafe_componentWillUpdate = logger('inner componentWillUpdate');
537+
UNSAFE_componentWillUpdate = logger('inner componentWillUpdate');
538538
componentDidUpdate = logger('inner componentDidUpdate');
539539
componentWillUnmount = logger('inner componentWillUnmount');
540540
render() {
@@ -583,7 +583,7 @@ describe('ReactComponentLifeCycle', () => {
583583
log.push('render');
584584
return <Child />;
585585
},
586-
unsafe_componentWillMount() {
586+
UNSAFE_componentWillMount() {
587587
log.push('will mount');
588588
},
589589
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-
unsafe_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-
unsafe_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-
unsafe_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-
unsafe_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-
unsafe_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-
unsafe_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-
unsafe_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-
unsafe_componentWillMount() {
1380+
UNSAFE_componentWillMount() {
13811381
log.push(this.props.name + ' componentWillMount');
13821382
}
13831383
render() {
@@ -1556,7 +1556,7 @@ describe('ReactCompositeComponent', () => {
15561556
};
15571557
}
15581558

1559-
unsafe_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-
unsafe_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-
unsafe_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-
unsafe_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-
unsafe_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-
unsafe_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-
unsafe_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-
unsafe_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-
unsafe_componentWillMount() {
234+
UNSAFE_componentWillMount() {
235235
this.setState({text: 'foo'});
236236
}
237237
render() {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ describe('ReactDOMServerLifecycles', () => {
3737
const log = [];
3838

3939
class Outer extends React.Component {
40-
unsafe_componentWillMount() {
40+
UNSAFE_componentWillMount() {
4141
log.push('outer componentWillMount');
4242
}
4343
render() {
@@ -47,7 +47,7 @@ describe('ReactDOMServerLifecycles', () => {
4747
}
4848

4949
class Inner extends React.Component {
50-
unsafe_componentWillMount() {
50+
UNSAFE_componentWillMount() {
5151
log.push('inner componentWillMount');
5252
}
5353
render() {
@@ -75,7 +75,7 @@ describe('ReactDOMServerLifecycles', () => {
7575

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

8181
// De-duped

0 commit comments

Comments
 (0)