I’m using Conform
in my forms and I have a problem cause data seems not persisting when going back and forth. When I click “next” and when I reached the 3rd step and click “previous” til I reach the 1st step, the data there disappeared.
Here’s my codesandbox: CLICK HERE
const [form, fields] = useForm({
lastResult,
constraint: getZodConstraint(schema[activeStep]),
shouldValidate: "onBlur",
shouldRevalidate: "onInput",
onValidate({ formData }) {
const parsed = parseWithZod(formData, { schema: schema[activeStep] });
if (parsed.status === "success") {
const payloadWithoutStep = Object.fromEntries(
Object.entries(parsed.payload).filter(
([key]) => key !== "active-step"
)
);
setFormValues((prev: any) => ({ ...prev, ...payloadWithoutStep }));
nextStep();
if (isLastStep) {
setSubmitted(true);
}
}
return parsed;
},
})