refactor: prefix lifecycle methods with UNSAFE_

Refs #7341
This commit is contained in:
Vladimir Gorej
2021-08-12 08:57:56 +02:00
parent a9285c5aa1
commit 8c79e2a375
18 changed files with 80 additions and 30528 deletions

30552
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -30,7 +30,7 @@ export default class ContentType extends React.Component {
}
}
componentWillReceiveProps(nextProps) {
UNSAFE_componentWillReceiveProps(nextProps) {
if(!nextProps.contentTypes || !nextProps.contentTypes.size) {
return
}

View File

@@ -117,7 +117,7 @@ export default class ExamplesSelectValueRetainer extends React.PureComponent {
}
_getValueForExample = (exampleKey, props) => {
// props are accepted so that this can be used in componentWillReceiveProps,
// props are accepted so that this can be used in UNSAFE_componentWillReceiveProps,
// which has access to `nextProps`
const { examples } = props || this.props
return stringifyUnlessList(
@@ -126,7 +126,7 @@ export default class ExamplesSelectValueRetainer extends React.PureComponent {
}
_getCurrentExampleValue = props => {
// props are accepted so that this can be used in componentWillReceiveProps,
// props are accepted so that this can be used in UNSAFE_componentWillReceiveProps,
// which has access to `nextProps`
const { currentKey } = props || this.props
return this._getValueForExample(currentKey, props || this.props)
@@ -169,7 +169,7 @@ export default class ExamplesSelectValueRetainer extends React.PureComponent {
}
}
componentWillReceiveProps(nextProps) {
UNSAFE_componentWillReceiveProps(nextProps) {
// update `lastUserEditedValue` as new currentUserInput values come in
const {

View File

@@ -78,7 +78,7 @@ export default class ExamplesSelect extends React.PureComponent {
}
}
componentWillReceiveProps(nextProps) {
UNSAFE_componentWillReceiveProps(nextProps) {
const { currentExampleKey, examples } = nextProps
if (examples !== this.props.examples && !examples.has(currentExampleKey)) {
// examples have changed from under us, and the currentExampleKey is no longer

View File

@@ -181,7 +181,7 @@ export class Select extends React.Component {
onChange && onChange(value)
}
componentWillReceiveProps(nextProps) {
UNSAFE_componentWillReceiveProps(nextProps) {
// TODO: this puts us in a weird area btwn un/controlled selection... review
if(nextProps.value !== this.props.value) {
this.setState({ value: nextProps.value })

View File

@@ -48,7 +48,7 @@ export default class ModelCollapse extends Component {
}
}
componentWillReceiveProps(nextProps){
UNSAFE_componentWillReceiveProps(nextProps){
if(this.props.expanded !== nextProps.expanded){
this.setState({expanded: nextProps.expanded})
}

View File

@@ -45,7 +45,7 @@ export default class ModelExample extends React.Component {
})
}
componentWillReceiveProps(nextProps) {
UNSAFE_componentWillReceiveProps(nextProps) {
if (
nextProps.isExecute &&
!this.props.isExecute &&

View File

@@ -30,7 +30,7 @@ export default class OnlineValidatorBadge extends React.Component {
return urlObject.toString()
}
componentWillReceiveProps(nextProps) {
UNSAFE_componentWillReceiveProps(nextProps) {
let { getConfigs } = nextProps
let { validatorUrl } = getConfigs()
@@ -91,7 +91,7 @@ class ValidatorImage extends React.Component {
img.src = this.props.src
}
componentWillReceiveProps(nextProps) {
UNSAFE_componentWillReceiveProps(nextProps) {
if (nextProps.src !== this.props.src) {
const img = new Image()
img.onload = () => {

View File

@@ -43,7 +43,7 @@ export default class ParamBody extends PureComponent {
this.updateValues.call(this, this.props)
}
componentWillReceiveProps(nextProps) {
UNSAFE_componentWillReceiveProps(nextProps) {
this.updateValues.call(this, nextProps)
}

View File

@@ -30,7 +30,7 @@ export default class ParameterRow extends Component {
this.setDefaultValue()
}
componentWillReceiveProps(props) {
UNSAFE_componentWillReceiveProps(props) {
let { specSelectors, pathMethod, rawParam } = props
let isOAS3 = specSelectors.isOAS3()

View File

@@ -11,14 +11,14 @@ export default class Schemes extends React.Component {
method: PropTypes.string,
}
componentWillMount() {
UNSAFE_componentWillMount() {
let { schemes } = this.props
//fire 'change' event to set default 'value' of select
this.setScheme(schemes.first())
}
componentWillReceiveProps(nextProps) {
UNSAFE_componentWillReceiveProps(nextProps) {
if ( !this.props.currentScheme || !nextProps.schemes.includes(this.props.currentScheme) ) {
// if we don't have a selected currentScheme or if our selected scheme is no longer an option,
// then fire 'change' event and select the first scheme in the list of options

View File

@@ -91,7 +91,7 @@ export default class OperationContainer extends PureComponent {
}
}
componentWillReceiveProps(nextProps) {
UNSAFE_componentWillReceiveProps(nextProps) {
const { response, isShown } = nextProps
const resolvedSubtree = this.getResolvedSubtree()

View File

@@ -130,7 +130,7 @@ export class JsonSchema_array extends PureComponent {
this.state = { value: valueOrEmptyList(props.value), schema: props.schema}
}
componentWillReceiveProps(props) {
UNSAFE_componentWillReceiveProps(props) {
const value = valueOrEmptyList(props.value)
if(value !== this.state.value)
this.setState({ value })

View File

@@ -55,7 +55,7 @@ export default class RequestBodyEditor extends PureComponent {
}, () => this.onChange(inputValue))
}
componentWillReceiveProps(nextProps) {
UNSAFE_componentWillReceiveProps(nextProps) {
if(
this.props.value !== nextProps.value &&
nextProps.value !== this.state.value

View File

@@ -25,7 +25,7 @@ export default class Servers extends React.Component {
this.setServer(servers.first().get("url"))
}
componentWillReceiveProps(nextProps) {
UNSAFE_componentWillReceiveProps(nextProps) {
let {
servers,
setServerVariableValue,

View File

@@ -50,7 +50,7 @@ export const makeMappedContainer = (getSystem, getStore, memGetComponent, getCom
handleProps(getSystem, mapping, props, {})
}
componentWillReceiveProps(nextProps) {
UNSAFE_componentWillReceiveProps(nextProps) {
handleProps(getSystem, mapping, nextProps, this.props)
}

View File

@@ -17,7 +17,7 @@ export default class Topbar extends React.Component {
this.state = { url: props.specSelectors.url(), selectedIndex: 0 }
}
componentWillReceiveProps(nextProps) {
UNSAFE_componentWillReceiveProps(nextProps) {
this.setState({ url: nextProps.specSelectors.url() })
}

View File

@@ -61,7 +61,7 @@ describe("<Schemes/>", function(){
expect(setSchemeSpy.mock.calls.length).toEqual(1)
// After an update
wrapper.instance().componentWillReceiveProps(props)
wrapper.instance().UNSAFE_componentWillReceiveProps(props)
// Should not be called again, since `currentScheme` is in schemes
expect(setSchemeSpy.mock.calls.length).toEqual(1)