Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editor broken when non-identity-stable nodeViews are specified #1

Closed
dminkovsky opened this issue Sep 8, 2020 · 3 comments
Closed
Labels

Comments

@dminkovsky
Copy link
Collaborator

dminkovsky commented Sep 8, 2020

When passing nodeViews as a prop to <ProseMirror />, the editor is broken and React warns:

Warning: unstable_flushDiscreteUpdates: Cannot flush updates when React is already rendering.

This only happens when nodeViews identity changes from render to render. The issue appears to be related to EditorView#updateStateInner(), where nodeViews' identity changes causes the editor view to modify its "outer decoration". Judging by the code, this only happens in Chrome and related browsers.

Not sure what a proper fix for this would be.

For now, a workaround is to keep the nodeViews prop identity stable.

@dminkovsky dminkovsky changed the title Editor broken when nodeViews is specified as a <ProseMirror /> prop Editor broken when nodeViews is specified Sep 8, 2020
@dminkovsky dminkovsky changed the title Editor broken when nodeViews is specified Editor broken when non-identity-stable nodeViews are specified Sep 9, 2020
@dminkovsky
Copy link
Collaborator Author

dminkovsky commented Sep 15, 2020

Looks like rendering in useLayoutEffect works fine, and might solve this issue. Comes with the complexity of needing to make sure the component is mounted after initial render on client side.

@dminkovsky
Copy link
Collaborator Author

dminkovsky commented Nov 30, 2020

If useLayoutEffect is the fix (probably is not) then this might be useful: https://github.com/Andarist/use-isomorphic-layout-effect/blob/master/src/index.ts

@stale
Copy link

stale bot commented Apr 17, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant