plate
plate copied to clipboard
Plate remount is setting the editor to null
Description
It looks like Plate gets into a bad state when it’s remounted with the same id. The editor gets set to null.
Sandbox
https://codesandbox.io/s/friendly-sinoussi-3xgwx2 Clicking the remount button removes the editor
Environment
- slate:
- slate-react:
- browser: chrome
I prevent remount to prevent these kind of problem. In my side, remount cause it lost focus.
I prevent remount to prevent these kind of problem. In my side, remount cause it lost focus.
how to prevent remount? Could you paste the code please? I enter the same question
I'm using it in tiddlywiki, and I detect if the change is trigger by plate's onsave, then don't unmount react-com's root. If is trigger by 3rd party, then unmount react-dom, then remount.
https://github.com/tiddly-gittly/slate-write/blob/2b4ef9a7ecdb431000bf5e2ac860cf8fd5cdb65b/src/editor/index.ts#L42-L66
any updates on fixing this issue?
I think we can unmount remount parent component to avoid most of the problems, just like I do.
any updates on fixing this issue? . in my case , i need plate to remount frequently
Just wrap plate in a parent component, and remount that component by change the key or something.
Why do we even need to not render the content if the id is not found ? I mean, why not just render the children and be it ?
It would result into errors as the store needs to be created before the children subscribe to it using hooks. I've tried to fix the timing issue to no avail so I plan to migrate the plate store from zustand to jotai as jotai is using react context.
If anyone is interested, in my case it seems to work - not the timing issue, but it allows to Plate to be remounted. GL with this @zbeyens 🙂
I think this issue is plaguing me with serializing and de-serializing HTML. TypeError: Cannot read properties of null (reading 'plugins')
-- we use Plate to edit simple email contents and store the user input as HTML in the backend and want to rehydrate Plate with that HTML content. However, Editor is null... I think it's a race condition or a timing issue.