useFormFields Value and Dispatch

default discord avatar
Mark | Omniux
6 months ago

Just wanted to leave this in the community in case anyone is wanting to leverage the useFormFields functionality like useState;

    const [status, setStatus]: [string, (value: string) => void] = useFormFields(([fields, dispatch]) => [
        fields.status.value as string, (value: string) => dispatch({ type: 'UPDATE', path: 'status', value: value })

This will allow you to use status to get the value, and setStatus('') to make changes to your other form values.

    Open the post
    Continue the discussion in Discord
    Like what we're doing?
    Star us on GitHub!


    Connect with the Payload Community on Discord



    Can't find what you're looking for?

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