question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Code mirror value doesn't update with state change in v1.0.0

See original GitHub issue

Changing props.value does not re-render code mirror. This is a new issue in v1.0.0, previously this worked. Changing props.value via the onChange event works fine, but programmatically changing props.value does not call a re-render.

This can be reproduced with the following code.

class Editor extends Component {
    constructor() {
        super();
        this.state = { value: 'abc' };
    }

    render() {
        const { value } = this.state;
        console.log(value);
        return (
            <div>
                <CodeMirror value={value} />
                <button onClick={() => this.setState({ value: 'def' })}>Click to change value</button>
            </div>
        );
    }
}

This appears like it may have something to do with this change listed in the history file: fixed; Only updates the CodeMirror value if props.value has changed.

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:59
  • Comments:25 (3 by maintainers)

github_iconTop GitHub Comments

19reactions
skiddingcommented, Oct 2, 2017

PS. Try using referencing my branch in your package.json (temporarily!) to see it solves your issues as well:

"react-codemirror": "git://github.com/skidding/react-codemirror.git#106-fix-update",

Update: You might want to use https://github.com/scniro/react-codemirror2

16reactions
scnirocommented, May 25, 2017

+1 whats going on with this? Merging the PR fix would be soooooper

Read more comments on GitHub >

github_iconTop Results From Across the Web

CodeMirror Value not updating when props changed in React ...
I tried to update the value of my CodeMirror Component (imported from react-codemirror) using props received but the value doesn't change ...
Read more >
Codemirror Value Not Updating When Props Changed In ...
Changing props.value does not rerender code mirror. This is a new issue in v1.0.0 previously this worked. Changing props.value via the ...
Read more >
Ace, CodeMirror, and Monaco: A Comparison of the Code ...
I've been working on Replit for roughly six years now, and as the team has grown, I've focused on the IDE (what we...
Read more >
CodeMirror value is correct, but not displaying
The first file loaded always works fine, however when I switch I see nothing but the text in my html text area, even...
Read more >
RHSA-2022:5069 - Security Advisory - Red Hat Customer Portal
This release includes a security update for Red Hat OpenShift ... in orphaned code; BZ - 1994820 - machine controller doesn't send vCPU ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found