uiwjs / uiwjs/react-codemirror
Multiple CodeMirrors in a List Breaks
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 2.3k
- Forks
- 161
- PR merge metrics
- No merged PRs in 30d
Description
I am trying to show a list of CodeMirrors, but when multiple of the component is loading in a list, it fails to properly handle state updates.
Steps to reproduce (When key={index})
- Click on codemirror instance 1, type in 1
- Click on codemirror instance 2, type in 2
- No text will appear in instance 2, and the text from type 1 will disappear.
When key={cuid()}, then you can properly type in instance 1 and 2, but it triggers a re-render every character and you cannot type multiple characters at a time, so this doesn't work.
If you use a normal input element, this example works, but with code mirrors, it fails.
How do I show codemirror in a list and have it properly update to the correct states?
https://codesandbox.io/s/uiwjs-react-codemirror-issues-294-forked-74fp81
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 the linked CodeSandbox reproduction and the React CodeMirror component behavior when multiple instances render in a list. Reproduce the key={index} and key={cuid()} cases, then trace how each instance handles state updates. Done means two CodeMirror instances retain and independently display typed text without rerendering on every character.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100