In this codesandbox, I can still see the previous values that were saved. However, if I'll use an incognito, the codesandbox is working properly. It does not show the previous values that were submitted.
This is the codesandbox: https://codesandbox.io/s/react-hook-form-data-in-step-1-and-step-2-editing-the-variable-names-wgv169?file=/src/Step2.js
Clearing up the state:
export default function clearAction(state, payload) {
return {
data: {}
};
}
const Step2 = (props) => {
const { state, action } = useStateMachine(updateAction, clearAction);
const onSubmit = (data) => {
action(data);
action();
push("/result");
};
return (
<form onSubmit={handleSubmit(onSubmit)}>
//input fields here
</form>
);
};