似乎不能在表单中使用存储
const data = {
signin: {
email: "",
password: ""
}
};
const MyContextTSX = createContext(data);
const Store = (props: any) => {
return (
<MyContextTSX.Provider value={data}>{props.children}</MyContextTSX.Provider>
);
};
以其他形式使用上述代码
const useForm = ({ callback }: any) => {
const signinData = useContext(Store); // Store shows error
而不是存储,你必须使用 MyContextTSX 作为 arg in useContext(MyContextTSX(
const signinData = useContext(MyContextTSX);