hashmd icon indicating copy to clipboard operation
hashmd copied to clipboard

React component triggers onChange function when value-prop changes. This causes a bunch of annoying bugs.

Open Discordius opened this issue 4 years ago • 1 comments

The current React implementation of the editor fires the onChange function when the value prop changes. This causes spurious rerenders and is in conflict with the standards of what I've seen basically any other editor library use.

This was causing a particularly gnarly bug in my use-case where I had a large data structure where the editor could be used to edit various different parts of it. When I pointed the editor at a different part of it (by changing its value and the passed onChange function) it would execute the onChange function of the previous render (together with the fieldName of the previous render), causing it to override the previous text in the datastructure with the text of the new part that was being navigated to. This of course was not the intended result and required some ugly hacks to work around.

Discordius avatar Apr 13 '21 05:04 Discordius

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] avatar Mar 27 '22 02:03 github-actions[bot]