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.
Saved the day, thanks!
hey
@191776538205618177, could you guide me if i want to add a row to type:array using dispatch.
I'd need to take another look at the docs. This was posted a LOOONNG time ago, probably around v1 or pre-v1. So much has changed now in the way client components are handled - this logic may no longer apply
hey
@191776538205618177thanks for your reply, i managed to solve it
though it looks like you'd just change type to ADD_ROW
i used the addFieldRow method
Star
Discord
online
Get dedicated engineering support directly from the Payload team.