Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CORE-908] Remove UNSAFE_componentWillReceiveProps #1

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "redux-form",
"version": "8.3.9",
"version": "8.3.10",
"description": "A higher order component decorator for forms using Redux and React",
"main": "./lib/index.js",
"module": "./es/index.js",
Expand Down
10 changes: 5 additions & 5 deletions src/ConnectedFields.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ export default function createConnectedFields(structure: Structure<any, any>) {
this.onBlurFns[name] = event => this.handleBlur(name, event)
})

UNSAFE_componentWillReceiveProps(nextProps: Props) {
componentDidUpdate(prevProps: Props) {
if (
this.props.names !== nextProps.names &&
(size(this.props.names) !== size(nextProps.names) ||
nextProps.names.some(nextName => !this.props._fields[nextName]))
this.props.names !== prevProps.names &&
(size(this.props.names) !== size(prevProps.names) ||
this.props.names.some(nextName => !this.props._fields[nextName]))
) {
// names has changed. The cached event handlers need to be updated
this.prepareEventHandlers(nextProps)
this.prepareEventHandlers(this.props)
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/createFields.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ export default function createFields(structure: Structure<any, any>) {
this.registerFields(this.props.names)
}

UNSAFE_componentWillReceiveProps(nextProps: Props) {
if (!plain.deepEqual(this.props.names, nextProps.names)) {
componentDidUpdate(prevProps: Props) {
if (!plain.deepEqual(this.props.names, prevProps.names)) {
const { props } = this
const { unregister } = props._reduxForm
// unregister old name
Expand Down
4 changes: 2 additions & 2 deletions src/createFormValues.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ export default function createValues({ getIn }: Structure<any, any>): FormValues
this.updateComponent(props)
}

UNSAFE_componentWillReceiveProps(props) {
componentDidUpdate() {
if (typeof firstArg === 'function') {
this.updateComponent(props)
this.updateComponent(this.props)
}
}

Expand Down