uiwjs / uiwjs/react-codemirror

Multiple CodeMirrors in a List Breaks

Open
#309 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

demo
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})

  1. Click on codemirror instance 1, type in 1
  2. Click on codemirror instance 2, type in 2
  3. 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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.