Skip to content

Form inputs get cleared on validation inside a Chakra-UI modal #1744

Answered by DaniAkash
paambaati asked this question in General
Discussion options

You must be logged in to vote

The issue happened because the <EditModal> component is created as a function inside the <App> component & the hooks local to the App component are used inside EditModal. This is an antipattern in React & can be solved by moving EditModal outside of the App component & passing the required values as props.

The fixed form can be found here - https://codesandbox.io/s/hook-form-gp-discussion-xl2qb?file=/src/App.js

Replies: 13 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@paambaati
Comment options

@bluebill1049
Comment options

Answer selected by paambaati
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #1744 on May 31, 2020 12:22.