-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
bugSomething isn't workingSomething isn't workingenhancementNew feature or requestNew feature or request
Description
Is your feature request related to a problem? Please describe.
It is rather difficult to update shouldComponentUpdate functions for fields.
This is a function I am currently using for a slate based editor field:
shouldComponentUpdate(props) {
// Exclude value to check it later, exclude system(it contains ALL other fields), exclude
// onChange since its an arrow function(this could actually be considered a bug!)
const { value: currentValue, system: currentSystem, onChange: _1, ...currentProps } = this.props;
const { value: nextValue, system: nextSystem, onChange: _2, ...nextProps } = props;
// However we cannot fully ignore system since it contains the waiting prop.
if (currentSystem.waiting !== nextSystem.waiting) {
return true;
}
// Check if the other props have changed
if (!equals(currentProps, nextProps)) {
return true;
}
// Here is the actual check for changes
return !equals(currentValue.toJSON(), nextValue.toJSON());
}Describe the solution you'd like
Just having to write the last line - OR- a clearer cut picture on which props we need to check for updates and which not in a way that does not require us to know implementation details of this library.
Describe alternatives you've considered
Write code similar to the one above for every form in the future and update the code whenever anything in react-formilicious changes.
Not maintainable.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingenhancementNew feature or requestNew feature or request