I am currently using presets(use saved form values) on reach hook form in my Nextjs shadecn project
const form = useForm({
resolver: zodResolver(formSchema),
defaultValues: currentFormValue
// we also need to set default value here for the current form value
});
// Function to update form values when a preset is selected
const updateFormValuesWithPreset = (presetValues) => {
// Update form values with the preset values
form.reset(presetValues);
};
// Effect to update form values when currentFormValue changes
useEffect(() => {
if (currentFormValue) {
updateFormValuesWithPreset(currentFormValue);
}
}, [currentFormValue]);
Somhow it is not triggering & updating form value when user select a preset. Where I am using set hook to update currentFormValue. Anyone can tip in? Thanks