Closed bzbetty closed 1 year ago
trying to use with https://react-hook-form.com/ and make a multi page wizard form.
A guard method seemed ideal to do validation between pages, however the validation function I need to call is async.
Is there any known way to have an async guard?
example const [state, send] = useStateMachine({ initial: 'name', states: { name: { on: { BACK: { }, NEXT: { target: 'location', guard: async ({ context, event }) => { //ERROR return await trigger(["field1", "field2]); }, } } }, etc
const [state, send] = useStateMachine({ initial: 'name', states: { name: { on: { BACK: { }, NEXT: { target: 'location', guard: async ({ context, event }) => { //ERROR return await trigger(["field1", "field2]); }, } } }, etc
trying to use with https://react-hook-form.com/ and make a multi page wizard form.
A guard method seemed ideal to do validation between pages, however the validation function I need to call is async.
Is there any known way to have an async guard?
example
const [state, send] = useStateMachine({ initial: 'name', states: { name: { on: { BACK: { }, NEXT: { target: 'location', guard: async ({ context, event }) => { //ERROR return await trigger(["field1", "field2]); }, } } }, etc