작성
·
290
0
const dispatch = useAuthDispatch(); 에도
마찬가지로 타입 추론이 unknown 타입으로 되서 그림과 같이 빨간줄이 뜨는데 어떻게 처리해야 하나요?
export const useAuthDispatch = () => useContext(DispatchContext) as any;
위와 같이 처리하는 방법도 괜찮나요??
답변 1
0
안녕하세요
그렇게 하셔도 되지만
위에서
const DispatchContext = createContext<any>(null);
이렇게 해주시지 않았나요 ~ ?
아 const DispatchContext = createContext(null) as any로 했었어서
useContext(DispatchContext)에서 다시 unknown으로 변경이 되는군요
const DispatchContext = createContext<any>(null)로 변경하니까 해결됐습니다
감사합니다~