-
Notifications
You must be signed in to change notification settings - Fork 49.8k
Validate props on context providers #12658
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
Changes from 9 commits
1193a94
1184974
2547b22
b596129
b26897e
ed42cac
63ef731
ea50645
683fdfe
5a38c06
bdfab1f
ab53c91
c500f24
af05d8e
dd0ea94
c419075
79ea1b5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,7 @@ import type {NewContext} from './ReactFiberNewContext'; | |
| import type {HydrationContext} from './ReactFiberHydrationContext'; | ||
| import type {FiberRoot} from './ReactFiberRoot'; | ||
| import type {ExpirationTime} from './ReactFiberExpirationTime'; | ||
| import checkPropTypes from 'prop-types/checkPropTypes'; | ||
|
|
||
| import { | ||
| IndeterminateComponent, | ||
|
|
@@ -885,6 +886,15 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>( | |
| const newValue = newProps.value; | ||
| workInProgress.memoizedProps = newProps; | ||
|
|
||
| if (__DEV__) { | ||
| checkPropTypes( | ||
| workInProgress.type.propTypes, | ||
| newProps, | ||
| 'prop', | ||
| 'ReactProvider', | ||
|
||
| ); | ||
|
||
| } | ||
|
|
||
| let changedBits: number; | ||
| if (oldProps === null) { | ||
| // Initial render | ||
|
|
||
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.
Let's only call
checkPropTypesifworkInProgress.type.propTypesexists. Read it before the call and then, if it exists, call the function, passing it as an argument.