Skip to content

Slate.js plugin | Error: The useSlate hook must be used inside the <Slate> component's context. #2271

Answered by jmikrut
franckmartin asked this question in Q&A
Discussion options

You must be logged in to vote

Hey there - this is because you have two copies of Slate in use - one local, and one within Payload. Instead of installing a separate copy of slate / slate-react, just use Payload's copies.

You could also try making sure to match the slate and slate-react versions exactly to what Payload uses internally in its own package.json.

Last thing, if you do want to have additional copies of Slate installed, you could write a Webpack alias to make sure that when you import Slate, it always points to the same copy of Slate.

This is a React problem more than anything, with how it handles context / etc. But this should be what you need here.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@franckmartin
Comment options

@shaneheyworth
Comment options

Answer selected by franckmartin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants