JedWatson / react-codemirror

Codemirror Component for React.js
MIT License
1.56k stars 262 forks source link

Changing the value in store will not update the component & contents #121

Open OsamaShabrez opened 7 years ago

OsamaShabrez commented 7 years ago

If CodeMirror value is changed at the backend, directly in the store the component does not reflect the latest changes.

There is no way I have found so far that can force update the component. Any help would be greatly appreciated.

zane-c commented 7 years ago

+1

marcofugaro commented 7 years ago

I also have this issue

scniro commented 7 years ago

@OsamaShabrez @zane-c @marcofugaro hey all, I too was having similar issues and threw up react-codemirror2 which doesn't seem to suffer from this. I'm planning to maintain it moving forward. Feel free to open up an issue on the repo should anything seem off and I'll be on it 😎

jaredly commented 7 years ago

here's the offending commit https://github.com/JedWatson/react-codemirror/commit/339b5975724cde338301f4c6842f2d52b4773e76

themre commented 7 years ago

ugly hack:

<CodeMirror ref={el => this.cm = el} ... />

and then in the code where you want to update: this.cm.codeMirror.setValue(newValue)

inoas commented 7 years ago

@JedWatson can you take a look at https://github.com/JedWatson/react-codemirror/commit/339b5975724cde338301f4c6842f2d52b4773e76 and possibly just reverse it as @jaredly pointed out?

ticky commented 6 years ago

I just spent an hour chasing this bug. 🤦🏻‍♀️ Thanks for the (working) fork, @scniro!