Code mirror value doesn't update with state change in v1.0.0
See original GitHub issueChanging 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:
- Created 6 years ago
- Reactions:59
- Comments:25 (3 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
PS. Try using referencing my branch in your package.json (temporarily!) to see it solves your issues as well:
Update: You might want to use https://github.com/scniro/react-codemirror2
+1 whats going on with this? Merging the PR fix would be soooooper