react-codemirror icon indicating copy to clipboard operation
react-codemirror copied to clipboard

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

Open OsamaShabrez opened this issue 8 years ago • 7 comments

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.

OsamaShabrez avatar Jun 28 '17 12:06 OsamaShabrez

+1

zane-c avatar Jun 28 '17 16:06 zane-c

I also have this issue

marcofugaro avatar Jul 03 '17 16:07 marcofugaro

@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 😎

scniro avatar Jul 12 '17 13:07 scniro

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

jaredly avatar Jul 13 '17 22:07 jaredly

ugly hack:

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

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

themre avatar Jul 19 '17 08:07 themre

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

inoas avatar Jul 19 '17 14:07 inoas

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

ticky avatar Sep 23 '17 01:09 ticky