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
support for React's Context #2916
Comments
It's inherently impossible to make context type-safe. Since it's passed implicitly, it can only be verified at runtime |
Thanks for the clarification @vkurchatkin ! |
Jumping in this as I'm running into the same situation. Wouldn't a 4th generic argument solve this?
Edit: Got bored, something like this: https://github.com/milesj/flow/commit/76e9495d47732ee335754af6b63fd2cdae75be14 |
@vkurchatkin any updates on this seems @milesj update is working, right? |
@vkurchatkin can you please provide some information on this ticket as the update from @milesj works? |
@vkurchatkin any updates on this? |
@awitherow the problem with this approach is that it doesn't really provide any safety, but breaks a lot of existing code. I'm not sure that it's worth it |
Well is there a way we could make this happen in some way? Assuming flow is the future, our project has completely switched from using propTypes to using flow... except it does not work in 3 lines of code where we use context types. It would be great to be able to remove the package Or is it a "not possible". |
I would say that, no it's not possible. And context requires propTypes anyway. |
Why is this not possible? Flow knows statically all of the ways the components could be put together. Can't it find type problems in the context tree? |
All we really need (I want) to solve/type annotate is accessing context in components:
|
@milesj I take a try but it not work (with VSCode). What's I want to see here is like the lint of But in fact, what I really need is just got the context type lint from the |
Well, I resolved it by define the context again ( What? I found that I could not upload the screenshot! It seems all the image from import { Context, ContextType } from './...';
class extends Component {
static contextType = Context;
context: ContextType;
...
} |
This issue was about the legacy context API, not the new one. |
@milesj oh, I'm sorry I didn't notice it... |
It seems that at the moment there is no support for React Context.
I am trying to make this code type-safe with flow but it does not seem to be possible.
The text was updated successfully, but these errors were encountered: