I was using version 3.1.4 before and the action(data) works, however, after I updated it to the latest version. It now says that action(data) is not a function. How can I fix this and what is the problem?
The action(data) are present in Step1.js and Step2.js
export default function updateAction(state, payload) {
return {
...state,
yourDetails: {
...state.yourDetails,
...payload
}
};
}
const { state, action } = useStateMachine({ updateAction });
const onSubmit = (data) => {
// action(data);
console.log(data, "d");
const newOrder = [];
data.order.forEach(({ product, variation }) => {
const newVariantion = [];
variation.forEach(({ qty, color }) => {
newVariantion.push({ qty: parseInt(qty), color });
});
newOrder.push({ product, variation: newVariantion });
});
action(newOrder);
console.log(newOrder);
navigate("/step2", newOrder);
};
codesandbox: https://codesandbox.io/s/react-hook-form-wizard-form-from-reddit-forked-ouy64e?file=/src/Step1.js:720-1179