Commit 22510f3
committed
Don't render
Fixes a bug where the state for the form fields wasn't being populated
by the initial values coming from props.
As the form was always rendered, regardless of whether anything was
currently being edited, the initial values coming from the props and
passed to the `useState` calls were empty. Then when a particular
section was selected, these props changed to reflect the data from that
section. However, `useState` only uses the initial values from the
*first render*, so it was ignoring these updated props, and retaining
the empty values.
The solution is not to render the form while nothing is being edited,
and then render it when a section is selected for editing. That way each
time a section is selected for editing, the form is considered a new
addition to the tree, and therefore the initial data coming from props
on the "first render" is the section data.EditDialog when not editing1 parent 53f90f6 commit 22510f3
File tree
2 files changed
+8
-26
lines changed2 files changed
+8
-26
lines changedLines changed: 0 additions & 22 deletions
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
27 | 31 | | |
28 | 32 | | |
29 | 33 | | |
30 | | - | |
31 | | - | |
| 34 | + | |
| 35 | + | |
32 | 36 | | |
33 | | - | |
| 37 | + | |
34 | 38 | | |
35 | 39 | | |
36 | | - | |
| 40 | + | |
37 | 41 | | |
38 | 42 | | |
39 | 43 | | |
| |||
0 commit comments