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

feat: Avoid warnings when using useFormStates. #113

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

stephenh
Copy link
Contributor

Currently when tables call getFormState(fragment), from within their render method (mobx observer), we immediately diff the fragment against the prior fragment, and if it's different, push the update into the formState proxy.

This "update a proxy in a render method" will tick/dirty any other components/observers that are also watching this mobx proxy.

The regular useFormState avoids this by writing to the proxy via a useEffect, which moves the dirty-via-setState out of render methods.

This PR is a spike/proof-of-concept to apply the same useEffect approach to useFormStates, by turning getFormState effectively into a hook itself.

Currently when tables call `getFormState(fragment)`, from within their
render method (mobx observer), we immediately diff the fragment against
the prior fragment, and if it's different, push the update into the
formState proxy.

This "update a proxy in a render method" will tick/dirty any other
components/observers that are also watching this mobx proxy.

The regular useFormState avoids this by writing to the proxy via a
useEffect, which moves the dirty-via-setState out of render methods.

This PR is a spike/proof-of-concept to apply the same useEffect
approach to useFormStates, by turning getFormState effectively into
a hook itself.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant