How to rewrite logics for saving state of component without using arrow functions in Nextjs code?
import { useState, createContext, useContext } from "react";
export const FormContext = createContext();
export default function FormProvider({ children }) {
const [data, setData] = useState({});
const setFormValues = (values) => {
setData((prevValues) => ({
...prevValues,
...values,
}));
};
return (
<FormContext.Provider value=>
{children}
</FormContext.Provider>
);
}
export const useFormData = () => useContext(FormContext);
Via Active questions tagged javascript - Stack Overflow https://ift.tt/zP4yRmk
Comments
Post a Comment