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

flushSync was called from inside a lifecycle method #512

Closed
JasonColeyNZ opened this issue Mar 11, 2024 · 5 comments · Fixed by #513
Closed

flushSync was called from inside a lifecycle method #512

JasonColeyNZ opened this issue Mar 11, 2024 · 5 comments · Fixed by #513

Comments

@JasonColeyNZ
Copy link

Describe the bug and the expected behavior

This error is appearing in 1.0.3

Conform version

v1.0.3

Steps to Reproduce the Bug or Issue

useEffect(() => {
form.reset()
}, [formData]) //from useLoaderData()

What browsers are you seeing the problem on?

Chrome

Screenshots or Videos

No response

Additional context

If I wrap the form.reset() in a queueMicrotask the error will go away. The reason I use the formReset is that I have a form as shown below, where the items are selected in the route to the left (the list) and a detail route the right side. Using form.reset() seems to be the best way to have the form update with the newly selected item received in the detail routes useLoaderData

Screenshot 2024-03-11 at 5 45 52 pm
@JasonColeyNZ
Copy link
Author

I am doing further testing, but it appears the form.reset() may not be needed anymore.... I had to do this in earlier version of conform to have the detail section update. I will do more testing and see if this can be removed going forwards.

@JasonColeyNZ
Copy link
Author

OK after some quick testing, yes I do have to use form.reset() in a useEffect as the form isn't being reloaded, rather the data being updated.

@edmundhung
Copy link
Owner

Thanks for reporting. This looks like a bug from #496. I will revert it.

@edmundhung
Copy link
Owner

I have published v1.0.4 with the problematic changes reverted for now.

@JasonColeyNZ
Copy link
Author

JasonColeyNZ commented Mar 11, 2024 via email

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 a pull request may close this issue.

2 participants