Skip to content

typescript로 마이그레이션 시 useContext에서의 type 지정 #642

Answered by woohm402
JiyeonP asked this question in Q&A
Discussion options

You must be logged in to vote

저는 보통 export 할 때

type AuthContextType = {
  login: boolean;
  등등
}

export const useAuthContext = () => useContext(AuthContext) as AuthContextType;

이런 식으로 export해 줍니다!

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@JiyeonP
Comment options

JiyeonP Nov 5, 2021
Collaborator Author

@woohm402
Comment options

@JiyeonP
Comment options

JiyeonP Nov 5, 2021
Collaborator Author

@woohm402
Comment options

@JiyeonP
Comment options

JiyeonP Nov 5, 2021
Collaborator Author

Answer selected by woohm402
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
React React 관련 내용 question 질문으로 사용될 이슈
2 participants