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

Created on 27 May 2020  路  9Comments  路  Source: facebook/react

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.

Enhancement good first issue (taken)

Most helpful comment

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

All 9 comments

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

@heath-freenome I would love to take it if you don't mind, it's that okay?

This issue is all yours, @brunogonzales

I've added the "good first issue (taken)" label so that others will know not to start work on the issue. If you change your mind about the issue, no worries! Just let me know so that I can remove the label and free it up for someone else to claim.

Cheers!

@brunogonzales go for it! I wouldn't have time to get to it for a month at least. Please tag me on the PR as I would love to see the solution.

@brunogonzales Have you started working on it ?? 馃槄
I have made changes locally to add warning and (added + updated) the tests but not really sure if that is the correct way to do that.
I am not sure if I am supposed to raise a pr if an issue is taken 馃槄 @bvaughn
but tried to do this, even when taken, because this seemed a bit easy to do with the limited knowledge I have 馃槗 and could get me to familiarize myself with this code.
If you have not started work on it or not planning to pick soon, shall I create PR with what I have done?
Else if you have started, please feel free to ignore, but please tag me on the PR, I would love to see the solution.

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

@bvaughn How to get reviewers added on pr ?
Is that automated/queued or, need to comment/tag someone on PR ??

Hi! Is this issue still open and available? I would be happy to take it up if no one is working on it ATM.
Thanks

Hi! Is this issue still open and available? I would be happy to take it up if no one is working on it ATM.
Thanks

This was fixed in #19054 and released in React 17 Realease Candidate. We just forgot to close this issue.

Was this page helpful?
0 / 5 - 0 ratings