Unexpected <Form> behavior in refactored tutorial #10999
-
The My refactoring was straightforward -- I migrated the behavior from I add some basic HTML to show the property values of the incoming In the second screen capture below, I've highlighted the several places where the displayed value of If I navigate from a selected contact back to the index page and then click a different contact from the sidebar, the outlet renders as expected. This behavior is therefore specific to a navigation from something like The first screen capture shows the result of clicking an item in the left-hand sidebar. The outlet is rendering the expected data. The second screen capture shows the result then clicking the next item in the left-hand side-bar. I've highlighted the unexpected fields of the form. Here is the refactored content of
I appreciate your attention and invite your thoughts and suggestions. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
This looks like a bug in The work-around is to import and use the
Without this workaround, the 'defaultValue' property of each input of the form is set to the value of the corresponding field of The That last render does NOT cause the form to be updated, and the result is an incorrect presentation of the form to the user. I appreciate your attention. I hope this apparent bug is at least addressed in the "issues" page -- it's a bit tedious to provide all the information requested by that form. |
Beta Was this translation helpful? Give feedback.
This looks like a bug in
react-router
to me. I found a work-around that solves the issue. I think that ifreact-router
is rendering correctly, then my work-around should have no effect.The work-around is to import and use the
useNavigation
hook, and short-circuit the rendering ofContact
ifnavigation.state
is not'idle'
:Import
useNavigation
hook:Invoke
useNavigation
inContact
:Short-circuit rendering if not idle