-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement custom createContext
util function
#1442
Conversation
… null and undefined
fix ModalContentContextValue type declaration
|
@@ -4,3 +4,44 @@ export const getReactVersion = () => { | |||
const [major, minor, patch] = React.version.split('.').map(Number) | |||
return { major, minor, patch } | |||
} | |||
|
|||
type NonNullableValue = object | number | string | boolean | bigint | symbol |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See: https://www.typescriptlang.org/docs/handbook/basic-types.html#object
object is a type that represents the non-primitive type, i.e. anything that is not number, string, boolean, bigint, symbol, null, or undefined.
undefined
, null
을 제외한 모든 타입 (primitive / reference)
if (contextValue === null) { | ||
throw new Error(`'${consumerName}' must be used within '${providerName}'`) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
꼭 특정 컨텍스트 아래에서만 사용해야하는 경우, 기본값에 null
을 지정하여 컨텍스트가 없을 경우 에러를 던지도록 합니다.
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #1442 +/- ##
==========================================
+ Coverage 87.16% 87.23% +0.07%
==========================================
Files 279 277 -2
Lines 3872 3862 -10
Branches 810 809 -1
==========================================
- Hits 3375 3369 -6
+ Misses 424 420 -4
Partials 73 73
☔ View full report in Codecov by Sentry. |
Chromatic Report🚀 Congratulations! Your build was successful! |
Self Checklist
CODEOWNERS
file.Related Issue
Fixes #1354
Summary
Context Provider와 useContext hook을 적은 코드로 쉽게 사용할 수 있게 해주는 커스텀 유틸 함수를 구현하고, 기존 코드를 교체합니다.
Details
undefined
와null
을 구분합니다. 기존FormControl
같은 케이스를 커버하기 위해null
일 경우에만 에러를 던지도록 구현했습니다.Breaking change or not (Yes/No)
No, 동작 변경은 없어야 함.
References
createContext
hook #1354