Closed tuppers360 closed 2 years ago
which codesandbox?
Sorry it is https://codesandbox.io/s/wild-dawn-ud8bq
it's working fine for me. after click on submit and refresh the button and the data persist correctly.
apologies for the delay, thanks for checking :-)
its works for me now too, must have been seeing things! sorry to have been a pain thought I was trying to help
When cloning the code sample from Code Sanbox (wild-dawn-ud8bq) you have to submit the form twice for the state to update?
Using:
import { GlobalState } from 'little-state-machine'; export function updateFirstLastName( state: GlobalState, payload: { firstname: string; lastname: string; } ) { console.log('state before:', state); console.log('payload:', payload); return { ...state, yourDetails: { ...payload, }, }; }
and
const onSubmit = (data: FormValues) => { actions.updateFirstLastName(data); console.log('state after:', state); };
this shows when changing any field it requires submission twice even when the payload is correct. I hope this is correct how I have gone about this.