-
Notifications
You must be signed in to change notification settings - Fork 25
Open
Labels
enhancementNew feature or requestNew feature or request
Description
The current implementation of getDerivedStateFromProps() polyfill is not fully correct: it doesn't demand null be returned which is required by the official spec.
function componentWillReceiveProps(nextProps) {
// Call this.constructor.gDSFP to support sub-classes.
var state = this.constructor.getDerivedStateFromProps(nextProps, this.state);
if (state !== null && state !== undefined) {
this.setState(state);
}
}Instead it should be:
...
if (state !== null && state !== undefined) {
this.setState(state);
}
if (state === undefined) {
console.warn('Warning: getDerivedStateFromProps(): A valid state object (or null) must be returned. You have returned undefined.');
}
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request