Like what we’re doing? Star us on GitHub!

Trying to implement a custom SlateJS element following the custom-website-series.

blupandaman
2 months ago
6

I have everything set up the same, but I keep getting this error on the front-end. What is set up differently in the custom-website series that allows one to use useSlate in their elements/leaves?



It is also used in the link element in the current build of payload

image.png
  • jmikrut
    Payload Team
    last month

    you should be able to

    useSlate

    for sure



    do you have a local copy of Slate installed?



    it must be on the same version otherwise your

    useSlate

    hook could be using a different copy of context vs. the internal one that Payload uses. You also might try and add a webpack alias to enforce that Webpack always uses the same copy of Slate, which would alleviate this even if you did have multiple copies installed

  • blupandaman
    last month

    Ok I will double check those and get back to you on that! Thanks for the tip

  • reepicheep05
    last month

    hey @blupandaman , wanted to ask what your solution was to this as I am getting the same error.



    I am starting a project and using the PayloadCMS website repo as a starting point. The

    useSlate

    hook is called in the richText field in the video Button component and I am getting this error whenever the Rich Text Editor is rendered in the admin.



    Edit: I believe this was caused by a

    slate

    version mismatch as pointed out by @jmikrut . I was able to resolve by uninstalling

    slate

    and

    slate-react

    . Thanks for the help!

Open the post
Continue the discussion in Discord
Can't find what you're looking for?
Get help straight from the Payload team with an Enterprise License.Learn More