You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The action mySubmitAction return the data key with the submitted data.
🤔 Expected Behavior?
When changing the value of the lastname input and submitting the form, I expect the input value to be preserved.
😯 Current Behavior
When changing the value of the lastname input and submitting the form, the lastname input value is changed back to the defaultValue.
💁 Possible Solution
The issue here is probably a lifecycle issue between : when/how react reset/empty the form (thanks react 19...), and the internal state of the TextField context.
🔦 Context
I admit using the useActionState hook put me on the edge. Not everything is really clear on how to use it. And especially by mix default value and form errors returned by the action. That how I discover this use case.
As workaround, I found that adding on the Form a key that is changed on each action execution (a random value returned by the action) works. At least it render the expected value in each field. It's not perfect : the focus is lost and this trigger to much rerender (witch could be an issue with big form).
Provide a general summary of the issue here
When using the RAC
TextField
with default value retrieve from theuseActionState
:And used like that:
The action
mySubmitAction
return thedata
key with the submitted data.🤔 Expected Behavior?
When changing the value of the
lastname
input and submitting the form, I expect the input value to be preserved.😯 Current Behavior
When changing the value of the
lastname
input and submitting the form, thelastname
input value is changed back to thedefaultValue
.💁 Possible Solution
The issue here is probably a lifecycle issue between : when/how react reset/empty the form (thanks react 19...), and the internal state of the
TextField
context.🔦 Context
I admit using the
useActionState
hook put me on the edge. Not everything is really clear on how to use it. And especially by mix default value and form errors returned by the action. That how I discover this use case.🖥️ Steps to Reproduce
Here a reproduction : https://codesandbox.io/p/devbox/grhqqp
I build three times the same form:
Input
,Label
andForm
(works fine),Input
,Label
,Form
andTextField
(does not work).Versions
The text was updated successfully, but these errors were encountered: