question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature request: have Context.Provider throw error if missing `value` prop

See original GitHub issue

Just 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:closed
  • Created 3 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
gaearoncommented, May 27, 2020

I think it does make sense to warn if !('value' in props). Want to send a PR?

2reactions
brunogonzalescommented, May 30, 2020

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found