networknt / networknt/react-schema-form
Array delete is not working (UI became out-of-sync of model)
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 356
- Forks
- 94
- Avg merge
- 19h 36m
- Merged PRs (30d)
- 4
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
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with src/Array.js around line 129 and reproduce the deletion sequence in the linked online playground using react-schema-form 0.2.8. Investigate the array element keys and verify that deleting the middle element removes the corresponding UI item while preserving the model values A and C.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100