Affected Packages
react
Version(s)
3.7.2
Bug Description
When using useEditor hook in React Strict Mode, the onCreate callback is called twice with two different editor instances, even though the hook correctly returns the same instance both times.
This is caused since the callback in the useState(() => new EditorInstanceManager(mostRecentOptions)) is called twice it causes the event onCreate event handler to be also called twice, each time with different instance.
I am not sure if this is related but the css styles are also not injected correctly as I suspect that the editor.destroy() of the second instance is called it unmounts the styles.
Browser Used
Chrome
Code Example URL
https://codesandbox.io/p/devbox/smoosh-framework-5tdhz9?workspaceId=ws_QZ6DpcrUC3wD6QbYWzwFrx
Expected Behavior
I feel like this can have several expected behaviours:
-
The events should not be called twice in the strict mode, or
-
The onCreate should be called with the same editor instance
-
Also I could see a world where this can be expected behaviour but should be at least documented.
Additional Context (Optional)
This is my first OS issue so I apologize in advance if I did something wrong 🙏
Dependency Updates
Affected Packages
react
Version(s)
3.7.2
Bug Description
When using
useEditorhook in React Strict Mode, theonCreatecallback is called twice with two different editor instances, even though the hook correctly returns the same instance both times.This is caused since the callback in the useState(() => new EditorInstanceManager(mostRecentOptions)) is called twice it causes the event
onCreateevent handler to be also called twice, each time with different instance.I am not sure if this is related but the css styles are also not injected correctly as I suspect that the editor.destroy() of the second instance is called it unmounts the styles.
Browser Used
Chrome
Code Example URL
https://codesandbox.io/p/devbox/smoosh-framework-5tdhz9?workspaceId=ws_QZ6DpcrUC3wD6QbYWzwFrx
Expected Behavior
I feel like this can have several expected behaviours:
The events should not be called twice in the strict mode, or
The onCreate should be called with the same editor instance
Also I could see a world where this can be expected behaviour but should be at least documented.
Additional Context (Optional)
This is my first OS issue so I apologize in advance if I did something wrong 🙏
Dependency Updates