Open
Description
In the following GIF image you can see that:
- I'm adding three elements to the array (A, B and C)
- I'm removing the second element (B)
- The model is fine (with values A and C)
- But in the UI we see that B remains visible (the last element is the one being removed - not rendered)
This happens because you are using array's index as the key for each li
component rendered in the Array react component.
React uses key prop to improve performance. From the documentation you can read the following:
Keys should be stable, predictable, and unique. Unstable keys (like those produced by Math.random()) will cause many nodes to be unnecessarily re-created, which can cause performance degradation and lost state in child components.
I don't know a solution for this. But the solution should be around defining a stable KEY for the array elements internally tracked by react-schema-form.
- You can try this yourself in the online playground
- react-schema-form version used: 0.2.8