You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Codemirror is a stateful editor, so it is not that great for a case you mention. You have to lookup through codemirrors docs, which are not that obvious.
Since this is a controlled component, the value is already set from outside. So, conceptually, all it takes to reset the value is to trigger setValue() with whatever new string.
For onChange function, you want to use useCallback. It's tricky to type it in one line, so I declare it separately, like this (I ended up using @uiw/react-codemirror which is more popular, but the gist should be the same here):
I want to reset the editor value externally
When I set
value={value}
, there are two problemsHow to solve this problem?
The text was updated successfully, but these errors were encountered: