Replies: 2 comments
-
I fixed the issue by using Might cause issues with History plugin on initial render. |
Beta Was this translation helpful? Give feedback.
0 replies
-
I was able to fix this by doing what the error message suggested - i.e. wrapping React.useEffect(() => {
const serializedEditorState = getEditorState(lexical);
const editorState = editor.parseEditorState(serializedEditorState);
queueMicrotask(() => {
editor.setEditorState(editorState);
});
}, [lexical, editor]); However, I too wonder if this is a great idea or not in React. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
use-case:
I'm using a read only LexicalComposer (editable: false) to display messages in a list. We have functionality that allows the user to modify the message which would cause this component to re-render/re-initialize.
To facilitate this we created a EditorStatePlugin like so:
This works to modify what's displayed but I'm seeing the following error in Chrome:
Warning: flushSync was called from inside a lifecycle method. React cannot flush when React is already rendering. Consider moving this call to a scheduler task or micro task.
I tried a variety of methods like moving the initial editor state to a useMemo but then the component doesn't update when the lexical changes. Am I doing something wrong?
Thanks in advance for any help!
Beta Was this translation helpful? Give feedback.
All reactions