작성
·
461
0
TypeError: dispatch is not a function
at _callee$ (login.tsx?11e1:20:10)
at tryCatch (runtime.js?ecd4:45:16)
at Generator.invoke [as _invoke] (runtime.js?ecd4:274:1)
at prototype.<computed> [as next] (runtime.js?ecd4:97:1)
at asyncGeneratorStep (_async_to_generator.mjs?949a:3:1)
at next (async_to_generator.mjs?949a:25:1)
라는 에러가 뜨는데 어디가 문젠지 모르겠습니다.. ㅠ
답변 4
1
0
// 제 코드입니다. ㅠㅠ
export const AuthProvider = ({ children }: { children: React.ReactNode }) => {
const [state, defaultDispatch] = useReducer(reducer, {
user: null,
authenticated: false,
loading: true,
});
const dispatch = (type: string, payload?: any) => {
defaultDispatch({ type, payload });
};
return (
<DispatchContext.Provider value={dispatch}>
<StateContext.Provider value={state}>{children}</StateContext.Provider>
</DispatchContext.Provider>
);
};
0
도움이 되었습니다