Avoid notify listener calls on field register when there's no subscriber #319
+147
−26
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello, I'm trying to address an issue with performance in react-final-form: final-form/react-final-form#667
The only way I could do this was to separate the registration and subscription of the field, slightly modifying the current
registerField
api to optionally accept the subscriber.The major performance issue that I've found with react-final-form was that it was using
registerField
to register for the first time to get the initial values, unregister, then register again for subscribing to the subsequent updates to the form. And each time it registered, it fired off notify subscription on all previously registered fields. So, if you are trying to render 100 fields on the screen, that's 2 registration per field and 10100 orn(n + 1)
notifications, I think. :)Anyway, I was trying to optimize this by not having to call notification on registration and avoid the second registration, so I've updated the api to what you see here.
I'll PR my changes for react-final-form shortly.React-final-form changes: final-form/react-final-form#727