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

get error when use serializeHtml with createBlockSelectionPlugin #2710

Closed
tomdyqin opened this issue Oct 20, 2023 · 2 comments
Closed

get error when use serializeHtml with createBlockSelectionPlugin #2710

tomdyqin opened this issue Oct 20, 2023 · 2 comments
Labels
bug Something isn't working duplicate This issue or pull request already exists has workaround plugin:block-selection plugin:serialize-html

Comments

@tomdyqin
Copy link
Contributor

tomdyqin commented Oct 20, 2023

Description

when use serializeHtml with createBlockSelectionPlugin, i got this error

react-dom.development.js:16227 Uncaught Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.
    at Object.throwInvalidHookError (react-dom.development.js:16227:9)
    at useContext (react.development.js:1618:21)
    at useAtomValue (index.js:684:24)
    at useAtom (index.js:743:5)
    at usePlateId (createPlateStore.ts:30:33)
    at usePlateStore (createPlateStore.ts:81:25)
    at usePlateSelectors (createPlateStore.ts:101:40)
    at useEditorRef (useEditorRef.ts:14:6)
    at useBlockSelectableState (BlockSelectable.tsx:28:18)
    at BlockSelectable (BlockSelectable.tsx:88:17)

after remove the createBlockSelectionPlugin the error is gone

Steps to Reproduce

Sandbox

Expected Behavior

no error

Environment

  • plate: 24.4.0
  • slate: 0.94.1
  • slate-react: 0.99.0
  • browser: chrome

Bounty

Click here to add a bounty via Algora.

Funding

  • You can sponsor this specific effort via a Polar.sh pledge below
  • We receive the pledge once the issue is completed & verified
Fund with Polar
@tomdyqin tomdyqin added the bug Something isn't working label Oct 20, 2023
@tomdyqin tomdyqin changed the title get error when use serializeHtml with createSelectOnBackspacePlugin get error when use serializeHtml with createBlockSelectionPlugin Oct 20, 2023
@12joan
Copy link
Collaborator

12joan commented Oct 20, 2023

Plate's serialize HTML pipeline is in need of a redesign to prevent errors like this from occurring. In the meantime, you can construct a temporary editor instance containing the minimum set of plugins required to serialize your editor value.

const tmpEditor = createPlateEditor({
  plugins: createPlugins([
    /* element and mark plugins */
  ], {
    components: {
      /* components for the same */
    },
  }),
});

// Use tmpEditor in serializeHtml

@zbeyens
Copy link
Member

zbeyens commented Nov 12, 2024

Tracked in #2804

@zbeyens zbeyens closed this as completed Nov 12, 2024
@zbeyens zbeyens added the duplicate This issue or pull request already exists label Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists has workaround plugin:block-selection plugin:serialize-html
Projects
None yet
Development

No branches or pull requests

3 participants