Use RichTextField, but not have onChange event

default discord avatar
rrums11 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.