Skip to content

Incompatibility with fast refresh in Next.js #113

Open
@kachkaev

Description

@kachkaev

👋 @d4rkr00t! Thanks a lot for this awesome package!

I’d like to share one issue I could not resolve myself, it is to do with React fast refresh in Next.js. Here is the MWE:
https://codesandbox.io/s/prosemirror-dev-tools-hot-reloading-mwe-d7osb?file=/pages/index.jsx

Kapture.2021-11-09.at.18.15.00.mp4

Scenario 1

  1. Open pages/index.jsx in dev mode

  2. Trigger fast refresh (e.g. add comment and save)

  3. Observe ProseMirror DevTools icon disappearing
    Expected: It stays up

  4. Trigger fast refresh again

  5. Observe ProseMirror DevTools icon re-appearing

Scenario 2

  1. Open pages/index.jsx in dev mode

  2. Bring up ProseMirror DevTools by clicking on the icon

  3. Trigger fast refresh

  4. Observe

    Unhandled Runtime Error
    NotFoundError: Node.removeChild: The node to be removed is not a child of this node
    

    Expected: No crash

Console output in both scenarios

Warning: componentWillReceiveProps has been renamed, and is not recommended for use. See https://reactjs.org/link/unsafe-component-lifecycles for details.

* Move data fetching code or side effects to componentDidUpdate.
* If you're updating state whenever props change, refactor your code to use memoization techniques or move it to static getDerivedStateFromProps. Learn more at: https://reactjs.org/link/derived-state
* Rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps to suppress this warning in non-strict mode. In React 18.x, only the UNSAFE_ name will work. To rename all deprecated lifecycles to their new names, you can run `npx react-codemod rename-unsafe-lifecycles` in your project source folder.

Please update the following components: Dock, JSONNestedNode, JSONTree, NodePicker
Warning: render(...): It looks like the React-rendered content of this container was removed without using React. This is not supported and will cause errors. Instead, call ReactDOM.unmountComponentAtNode to empty a container.
Home@webpack-internal:///./pages/index.jsx:33:67
App@webpack-internal:///./node_modules/next/dist/pages/_app.js:152:24
StyleRegistry@webpack-internal:///./node_modules/styled-jsx/dist/stylesheet-registry.js:231:28
ErrorBoundary@webpack-internal:///./node_modules/@next/react-dev-overlay/lib/internal/ErrorBoundary.js:26:47
ReactDevOverlay@webpack-internal:///./node_modules/@next/react-dev-overlay/lib/internal/ReactDevOverlay.js:90:20
Container@webpack-internal:///./node_modules/next/dist/client/index.js:305:24
AppContainer@webpack-internal:///./node_modules/next/dist/client/index.js:744:20
Root@webpack-internal:///./node_modules/next/dist/client/index.js:865:21

Any thoughts are welcome 🙌

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions