Skip to content
Discussion options

You must be logged in to vote

You want to "read" the particular form state to subscribe to it's value changes before it becomes reactive. You can destruct isValid to do so

+ const { isValid } = methods.formState
...
    <PageHeaderButton
-    disabled={!methods.formState.isValid}
+    disabled={!isValid}
    >

You can read more about this performance optimization in RHF using Proxy in formState rules section.

formState is wrapped with a Proxy to improve render performance and skip extra logic if specific state is not subscribed to. Therefore make sure you invoke or read it before a render in order to enable the state update.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by Moshyfawn
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants