Skip to content

Commit 1918b36

Browse files
committed
refactor: prefix lifecycle methods with UNSAFE_
Refs #7341
1 parent 14efcff commit 1918b36

18 files changed

+291
-30739
lines changed

package-lock.json

+263-30,711
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/core/components/content-type.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export default class ContentType extends React.Component {
3030
}
3131
}
3232

33-
componentWillReceiveProps(nextProps) {
33+
UNSAFE_componentWillReceiveProps(nextProps) {
3434
if(!nextProps.contentTypes || !nextProps.contentTypes.size) {
3535
return
3636
}

src/core/components/examples-select-value-retainer.jsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ export default class ExamplesSelectValueRetainer extends React.PureComponent {
117117
}
118118

119119
_getValueForExample = (exampleKey, props) => {
120-
// props are accepted so that this can be used in componentWillReceiveProps,
120+
// props are accepted so that this can be used in UNSAFE_componentWillReceiveProps,
121121
// which has access to `nextProps`
122122
const { examples } = props || this.props
123123
return stringifyUnlessList(
@@ -126,7 +126,7 @@ export default class ExamplesSelectValueRetainer extends React.PureComponent {
126126
}
127127

128128
_getCurrentExampleValue = props => {
129-
// props are accepted so that this can be used in componentWillReceiveProps,
129+
// props are accepted so that this can be used in UNSAFE_componentWillReceiveProps,
130130
// which has access to `nextProps`
131131
const { currentKey } = props || this.props
132132
return this._getValueForExample(currentKey, props || this.props)
@@ -169,7 +169,7 @@ export default class ExamplesSelectValueRetainer extends React.PureComponent {
169169
}
170170
}
171171

172-
componentWillReceiveProps(nextProps) {
172+
UNSAFE_componentWillReceiveProps(nextProps) {
173173
// update `lastUserEditedValue` as new currentUserInput values come in
174174

175175
const {

src/core/components/examples-select.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export default class ExamplesSelect extends React.PureComponent {
7878
}
7979
}
8080

81-
componentWillReceiveProps(nextProps) {
81+
UNSAFE_componentWillReceiveProps(nextProps) {
8282
const { currentExampleKey, examples } = nextProps
8383
if (examples !== this.props.examples && !examples.has(currentExampleKey)) {
8484
// examples have changed from under us, and the currentExampleKey is no longer

src/core/components/layout-utils.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ export class Select extends React.Component {
181181
onChange && onChange(value)
182182
}
183183

184-
componentWillReceiveProps(nextProps) {
184+
UNSAFE_componentWillReceiveProps(nextProps) {
185185
// TODO: this puts us in a weird area btwn un/controlled selection... review
186186
if(nextProps.value !== this.props.value) {
187187
this.setState({ value: nextProps.value })

src/core/components/model-collapse.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export default class ModelCollapse extends Component {
4848
}
4949
}
5050

51-
componentWillReceiveProps(nextProps){
51+
UNSAFE_componentWillReceiveProps(nextProps){
5252
if(this.props.expanded !== nextProps.expanded){
5353
this.setState({expanded: nextProps.expanded})
5454
}

src/core/components/model-example.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export default class ModelExample extends React.Component {
4343
})
4444
}
4545

46-
componentWillReceiveProps(nextProps) {
46+
UNSAFE_componentWillReceiveProps(nextProps) {
4747
if (
4848
nextProps.isExecute &&
4949
!this.props.isExecute &&

src/core/components/online-validator-badge.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export default class OnlineValidatorBadge extends React.Component {
3030
return urlObject.toString()
3131
}
3232

33-
componentWillReceiveProps(nextProps) {
33+
UNSAFE_componentWillReceiveProps(nextProps) {
3434
let { getConfigs } = nextProps
3535
let { validatorUrl } = getConfigs()
3636

@@ -91,7 +91,7 @@ class ValidatorImage extends React.Component {
9191
img.src = this.props.src
9292
}
9393

94-
componentWillReceiveProps(nextProps) {
94+
UNSAFE_componentWillReceiveProps(nextProps) {
9595
if (nextProps.src !== this.props.src) {
9696
const img = new Image()
9797
img.onload = () => {

src/core/components/param-body.jsx

+6-6
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export default class ParamBody extends PureComponent {
4343
this.updateValues.call(this, this.props)
4444
}
4545

46-
componentWillReceiveProps(nextProps) {
46+
UNSAFE_componentWillReceiveProps(nextProps) {
4747
this.updateValues.call(this, nextProps)
4848
}
4949

@@ -140,11 +140,11 @@ export default class ParamBody extends PureComponent {
140140
}
141141
<label htmlFor="">
142142
<span>Parameter content type</span>
143-
<ContentType
144-
value={ consumesValue }
145-
contentTypes={ consumes }
146-
onChange={onChangeConsumes}
147-
className="body-param-content-type"
143+
<ContentType
144+
value={ consumesValue }
145+
contentTypes={ consumes }
146+
onChange={onChangeConsumes}
147+
className="body-param-content-type"
148148
ariaLabel="Parameter content type" />
149149
</label>
150150
</div>

src/core/components/parameter-row.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export default class ParameterRow extends Component {
3030
this.setDefaultValue()
3131
}
3232

33-
componentWillReceiveProps(props) {
33+
UNSAFE_componentWillReceiveProps(props) {
3434
let { specSelectors, pathMethod, rawParam } = props
3535
let isOAS3 = specSelectors.isOAS3()
3636

@@ -127,7 +127,7 @@ export default class ParameterRow extends Component {
127127
: (schema && schema.getIn(["default"]))
128128
} else if (specSelectors.isOAS3()) {
129129
const currentExampleKey = oas3Selectors.activeExamplesMember(...pathMethod, "parameters", this.getParamKey())
130-
initialValue =
130+
initialValue =
131131
paramWithMeta.getIn(["examples", currentExampleKey, "value"]) !== undefined
132132
? paramWithMeta.getIn(["examples", currentExampleKey, "value"])
133133
: paramWithMeta.getIn(["content", parameterMediaType, "example"]) !== undefined

src/core/components/schemes.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ export default class Schemes extends React.Component {
1111
method: PropTypes.string,
1212
}
1313

14-
componentWillMount() {
14+
UNSAFE_componentWillMount() {
1515
let { schemes } = this.props
1616

1717
//fire 'change' event to set default 'value' of select
1818
this.setScheme(schemes.first())
1919
}
2020

21-
componentWillReceiveProps(nextProps) {
21+
UNSAFE_componentWillReceiveProps(nextProps) {
2222
if ( !this.props.currentScheme || !nextProps.schemes.includes(this.props.currentScheme) ) {
2323
// if we don't have a selected currentScheme or if our selected scheme is no longer an option,
2424
// then fire 'change' event and select the first scheme in the list of options

src/core/containers/OperationContainer.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export default class OperationContainer extends PureComponent {
9191
}
9292
}
9393

94-
componentWillReceiveProps(nextProps) {
94+
UNSAFE_componentWillReceiveProps(nextProps) {
9595
const { response, isShown } = nextProps
9696
const resolvedSubtree = this.getResolvedSubtree()
9797

src/core/json-schema-components.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ export class JsonSchema_array extends PureComponent {
130130
this.state = { value: valueOrEmptyList(props.value), schema: props.schema}
131131
}
132132

133-
componentWillReceiveProps(props) {
133+
UNSAFE_componentWillReceiveProps(props) {
134134
const value = valueOrEmptyList(props.value)
135135
if(value !== this.state.value)
136136
this.setState({ value })

src/core/plugins/oas3/components/request-body-editor.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export default class RequestBodyEditor extends PureComponent {
5555
}, () => this.onChange(inputValue))
5656
}
5757

58-
componentWillReceiveProps(nextProps) {
58+
UNSAFE_componentWillReceiveProps(nextProps) {
5959
if(
6060
this.props.value !== nextProps.value &&
6161
nextProps.value !== this.state.value

src/core/plugins/oas3/components/servers.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export default class Servers extends React.Component {
2525
this.setServer(servers.first().get("url"))
2626
}
2727

28-
componentWillReceiveProps(nextProps) {
28+
UNSAFE_componentWillReceiveProps(nextProps) {
2929
let {
3030
servers,
3131
setServerVariableValue,

src/core/plugins/view/root-injects.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export const makeMappedContainer = (getSystem, getStore, memGetComponent, getCom
5050
handleProps(getSystem, mapping, props, {})
5151
}
5252

53-
componentWillReceiveProps(nextProps) {
53+
UNSAFE_componentWillReceiveProps(nextProps) {
5454
handleProps(getSystem, mapping, nextProps, this.props)
5555
}
5656

@@ -76,7 +76,7 @@ const createClass = component => class extends Component {
7676
}
7777
}
7878

79-
const Fallback = ({
79+
const Fallback = ({
8080
name // eslint-disable-line react/prop-types
8181
}) => <div className="fallback">😱 <i>Could not render { name === "t" ? "this component" : name }, see the console.</i></div>
8282

src/plugins/topbar/topbar.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export default class Topbar extends React.Component {
1717
this.state = { url: props.specSelectors.url(), selectedIndex: 0 }
1818
}
1919

20-
componentWillReceiveProps(nextProps) {
20+
UNSAFE_componentWillReceiveProps(nextProps) {
2121
this.setState({ url: nextProps.specSelectors.url() })
2222
}
2323

test/unit/components/schemes.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ describe("<Schemes/>", function(){
6161
expect(setSchemeSpy.mock.calls.length).toEqual(1)
6262

6363
// After an update
64-
wrapper.instance().componentWillReceiveProps(props)
64+
wrapper.instance().UNSAFE_componentWillReceiveProps(props)
6565

6666
// Should not be called again, since `currentScheme` is in schemes
6767
expect(setSchemeSpy.mock.calls.length).toEqual(1)

0 commit comments

Comments
 (0)