Is there a way to make React Context type-safe with flow type?
For example :
Button.contextTypes = {
color: React.PropTypes.string
};
Element<typeof Component> is also the return type of React. createElement() . A React.Element<typeof Component> takes a single type argument, typeof Component . typeof Component is the component type of the React element. For an intrinsic element, typeof Component will be the string literal for the intrinsic you used.
Flow is a framework that, like TypeScript, promotes static typing in JavaScript. And like TypeScript it ships with React Native without any issues.
Unfortunately, it is inherently not possible because Context
is not known at compile time (so I was told).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With