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.

Use RichTextField, but not have onChange event

default discord avatar
rrums12 months ago

Hello!



I am trying to use RichTextField in my own component, but I realize that there is no onChange event that I can use.



now I use in my component, like this:


import RichTextField from "payload/dist/admin/components/forms/field-types/RichText";
const customComponent = (props) => {
  // some code
  const [body, setBody] = useState(null)
  // some code
  return (
  <>
    <RichTextField name={"body"} path={"body"} defaultValue={body}></RichTextField>
  </>
  )

}


I cannot handle the changes from the field and call setBody


Anyone has any idea on this? thanks



FYI, I use Payload 1.15, so it's SlateJS



solved by set rich text field with the same

name

prop as path in

<RichTextField>

, it will dispatch the value to that field

    Star on GitHub

    Star

    Chat on Discord

    Discord

    online

    Can't find what you're looking for?

    Get help straight from the Payload team with an Enterprise License.