Skip to content

feat: Avoid warnings when using useFormStates.#113

Draft
stephenh wants to merge 1 commit intomainfrom
fix-use-form-states-warning
Draft

feat: Avoid warnings when using useFormStates.#113
stephenh wants to merge 1 commit intomainfrom
fix-use-form-states-warning

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