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

Improve form state management #56

Open
wants to merge 6 commits into
base: next
Choose a base branch
from

Conversation

bsonntag
Copy link
Contributor

@bsonntag bsonntag commented Mar 28, 2022

WORK IN PROGRESS

This PR adds a rewrite of the module that aims to improve performance of forms.

In this implementation, instead of storing the form state in a useReducer, I'm storing it in a useRef. Each useField then uses use-subscription to subscribe to changes to a field's state. With this, only the fields that need to be updated will be re-rendered, instead of the whole form.

I tried to make the API change of the module as small as possible, so that this rewrite can be dropped-in in any application that is using @seegno/react-forms without much difficulty.

I also took the opportunity of the rewrite to change the module to TypeScript.

@bsonntag bsonntag force-pushed the feature/rewrite-with-subscriptions branch from ca4111e to de39e39 Compare March 28, 2022 12:47
@bsonntag bsonntag force-pushed the feature/rewrite-with-subscriptions branch from de39e39 to e0f22c8 Compare March 28, 2022 12:51
@@ -22,8 +22,9 @@
"bundle": "rm -rf dist && babel src --out-dir dist",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be changed to parcel right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. Parcel is only used to bundle the example application. The module is still bundled using Babel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants