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

useFormFields Value and Dispatch

Mark | Omniux
last week
0

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
    Can't find what you're looking for?
    Get help straight from the Payload team with an Enterprise License.Learn More