i am trying to update the values in the form state using react final form mutators by writing function below
const setProjectSelectedMutator = ([value], formState, tools) => {
tools.changeValue(formState, () => value && value.isSelectedInProject === true);
};
and then i am calling that mutate function like as below,
if (!once) {
if (
form &&
values.spaceType.mechanicalData[mappedLibrarySourceArray] &&
values.spaceType.mechanicalData[mappedLibrarySourceArray][index]
) {
// values.spaceType.mechanicalData[mappedLibrarySourceArray][
// index
// ].isSelectedInProject = true;
form.mutators.setProjectSelectedMutator(
values.spaceType.mechanicalData[mappedLibrarySourceArray][index].isSelectedInProject
);
setOnce(true);
}
}
i would like to set the boolean to true using the mutator function like as i am setting the same(mentioned in commented code) and getting an error like mutate is not a function
.
I am new to react final forms and could any one please suggest any idea or suggestion on this issue.
Thanks in advance
I think you forgot the second parameter that has the name of the field. I'ved added the "SOME NAME"
string to your code.
const setProjectSelectedMutator = ([value], formState, tools) => {
tools.changeValue(formState, "SOME NAME", () => value && value.isSelectedInProject === true);
};
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.