measuredco / puck

The visual editor for React
https://puckeditor.com
MIT License
5.27k stars 322 forks source link

history.historyStore is undefined when using Puck in Remix #658

Open lodybo opened 1 month ago

lodybo commented 1 month ago

I'm trying to write a plugin to use TinyMCE's rich text editor with Puck, heavily based on the puck-rich-text package (which uses Lexicon). I'm stuck at the implementation of the useSelected hook, which in puck-rich-text is being used to make sure the Rich Text Editor is actually selected before dispatching the onChange event.

I can add my editor and add content to it, but when I save my page (or rather, when the page is normally loaded), an error is thrown:

TypeError: Cannot read properties of undefined (reading 'hasPast')

It seems that history is undefined when returned from useAppContext().

I've created a reproduction here that you can run. The instructions are in the README.

IMythx commented 1 month ago

as i remember this error happens when u call usePuck hook outside of <Puck/> since this component returns the context provider so you can't consume the context outside of it