Closed hitsthings closed 1 year ago
I'm also using React 18 so maybe there is some weird complication with the double useEffect
in dev that they've added.
Hey @hitsthings thanks for the bug report! Yeah probably something like that is happening, it's not entirely bullet-proof hack. Any chance you can link a reproduction where the bug occurs? Like a TipTap example with dev-toolkit added? I want to add a test case for it if possible so I won't accidentally break it down the road.
https://github.com/hitsthings/prosemirror-dev-toolkit-tiptap-test shows it.
Commands I ran to set it up:
npx create-react-app@5.0.1 prosemirror-dev-toolkit-tiptap-test --template tiptap
npm install prosemirror-dev-toolkit npm start
Then I edited Tiptap.jsx to add an "s" after "World". This worked fine.
Then I ran applyDevTools() in a useEffect in the TipTap component. This worked fine.
Then I removed the "s" from "Worlds". This caused a console error similar to the reported one and the message no longer printed in the browser.
Every other edit thereafter had a similar error.
Hope that helps! I dunno how you would test HMR stuff. 😬 Thanks for the toolkit!
Thanks, that helped a lot! Should be fixed in 1.0.6 version
Awesome, thank you!
Looking at what's in
updateStateInner
, this happens becauseeditorView.docView
is null, which happens when the editorView is destroyed. I suspect HMR (maybe TipTap?) is destroying the editor view, but prosemirror-dev-toolkit is still listening to the dispatch event and updating props. I suspect this is fixed by aif (!view.docView) { return }
at the top of thesubscribeToDispatchTransaction
function.