Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Added warning to <Context.Provider> in case no value prop is provided #19054
Conversation
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 1603910:
|
|
did like the name of the code sandbox
wondering why cannot just update deps it old one |
|
Question, would making the |
@heath-freenome
But pointing to prop types gave me a better message, thanks for that, updating it now. |
|
React just recently removed all runtime dependencies to |
| if (!hasWarnedAboutUsingNoValuePropOnContextProvider) { | ||
| hasWarnedAboutUsingNoValuePropOnContextProvider = true; | ||
| console.error( | ||
| 'The prop `value` is required in `Context.Provider`, have you misspelled it', |
gaearon
Jun 30, 2020
Member
Let's reword this a bit:
The `value` prop is required for the `<Context.Provider>`. Did you misspell it or forget to pass it?
| if (!hasWarnedAboutUsingNoValuePropOnContextProvider) { | ||
| hasWarnedAboutUsingNoValuePropOnContextProvider = true; | ||
| console.error( | ||
| 'The prop `value` is required in `Context.Provider`, have you misspelled it', |
| @@ -263,13 +263,13 @@ describe('ReactContextValidator', () => { | |||
|
|
|||
| class Component extends React.Component { | |||
| render() { | |||
| return <TestContext.Provider />; | |||
| return <TestContext.Provider value={null} />; | |||
gaearon
Jun 30, 2020
Member
Make this value={undefined} instead and you won't need to change the message.
|
Small nits and this is good to go. |
f4097c1
into
facebook:master
|
Coolio, thanks. |
Summary
This PR aims to add a fix for #19020
packages/react-reconciler/src/ReactFiberBeginWork.new.jspackages/react-reconciler/src/ReactFiberBeginWork.old.jsIn feature flag saw
const enableNewReconciler = falsebut still cannot jump to any solid conclusions hence added in both.Test Added
packages/react-reconciler/src/__tests__/ReactNewContext-test.jstest to detect warning.Tests Updated Reason
As now
<Context.Provider>now throws a warning if value prop is not given, and hence updated the ones which were not having value prop to havenullnow.Points to be discussed
cc @brunogonzales @heath-freenome