-
Hi all! I have a question about the Modal component. If the modal is dismissed, we want the user to have a fresh form state when they re-open it, Currently, our plan is to manually clear all of the form state, but it's feeling a little hacky since the form wizard contains a variety of state data. We could also wrap the component in a HOC that unmounts if I wanted to check in with the team to see if this use case has come up in the past. And if so, is there a pattern the team recommends? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @robnit, Our Modal currently unmounts when closed, so form state should be cleared. Here's an example in Codesandbox: https://codesandbox.io/s/gallant-sutherland-1pebsd?file=/src/index.tsx What I imagine could be happening for you is that your form state is defined in a parent component (like this example) which doesn't unmount and resets the initial value of the form elements on mount. If this doesn't help solve your problem, could you create a minimal reproduction on Codesandbox please? |
Beta Was this translation helpful? Give feedback.
Hi @robnit,
Our Modal currently unmounts when closed, so form state should be cleared. Here's an example in Codesandbox: https://codesandbox.io/s/gallant-sutherland-1pebsd?file=/src/index.tsx
What I imagine could be happening for you is that your form state is defined in a parent component (like this example) which doesn't unmount and resets the initial value of the form elements on mount.
If this doesn't help solve your problem, could you create a minimal reproduction on Codesandbox please?