Feature request: have Context.Provider throw error if missing `value` prop
See original GitHub issueJust about every time I set up a new Context.Provider
, I end up accidentally specifying a values
prop rather than value
. While it’s a minor error, generally I build the container in which the provider resides and commit it to the code base before I ever use it. It’s only later when I go to use it that I realize I did it again. Since the Context.Provider
seems pretty much useless without a value
prop specified, I’d love it if there was a prop error if it is missing… especially if another prop is defined on the Context.Provider
instead.
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Context - React
The Provider component accepts a value prop to be passed to consuming components that are descendants of this Provider. One Provider can be...
Read more >How to use React Context effectively - Kent C. Dodds
useContext to get the provided context value from the nearest CountProvider . However, if there is no value, then we throw a helpful...
Read more >React Context is not defined no-undef - Stack Overflow
I need to use context provider and when I'm trying to use my context it's telling me NavContext' is not defined no-undef ....
Read more >An Introduction To Context Propagation In JavaScript
Provider — the return value createContext. This is an object with the “provider” property. The provider property is a component in itself, and ......
Read more >How to Work with the React Context API - Toptal
js app, it has probably happened to you. Prop drilling is the processing of getting data from component A to component Z by...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I think it does make sense to warn if
!('value' in props)
. Want to send a PR?@charlie1404 you can totally take this off my hands, I haven’t started working on it yet. Please tag me on your PR as I would like to know the solution too.