Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

Replacing useMemo with useState?

default discord avatar
mng93912 years ago
2

Currently, when I try to set a custom elements or leaves in the richText, I get

Cannot find a descendant at path

error which causes because useMemo is reevaluated on reloads so we might need to use useState instead?


https://github.com/payloadcms/payload/blob/master/src/admin/components/forms/field-types/RichText/RichText.tsx#L155

Related issue:

https://github.com/ianstormtaylor/slate/issues/4081

@281120856527077378

any thoughts?

  • discord user avatar
    jmikrut
    2 years ago

    This is probably due to your implementation, and you might be attempting to use an improper path or location



    that error is common when you try to update a node's properties (or similar) but the path that you're trying to do that against is not valid



    we do this often within Slate, all over the place in fact - so it's not something that is related to our use of

    useMemo

    vs.

    useState
  • default discord avatar
    mng93912 years ago
    @364124941832159242

    hmm, all i wanted to do is overriding the elements in the richText so thats what i did


    <RichText name="test" label="Test" admin={{elements:['h1', 'h2']}}/>

    then i got the error i mentioned but worked fine after i replaced useMemo with useState

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.