define propTypes for compatibility
See original GitHub issueHi,
a lot of react-native libraries use ReactNative.Text.propTypes.style or ReactNative.ViewPropTypes to define their own propTypes.
I know that propTypes are deprecated, but right now this causes a lot of “cannot read property style of undefined” errors with third party libraries.
My workaround is to monkey patch the prop types:
import * as ReactNative from 'react-native-web';
{
const PropTypes = require('prop-types');
ReactNative.Text.propTypes = { style: PropTypes.any };
ReactNative.View.propTypes = { style: PropTypes.any };
ReactNative.Image.propTypes = { style: PropTypes.any };
ReactNative.ViewPropTypes = { style: PropTypes.any };
}
I wonder if it makes sense to have the propTypes still defined by react-native-web for better user experience or just wait until propTypes are removed from the third party libraries.
Cheers Mo
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Typechecking With PropTypes - React
PropTypes exports a range of validators that can be used to make sure the data you receive is valid. In this example, we're...
Read more >prop-types - npm
Start using prop-types in your project by running `npm i prop-types`. ... This package is compatible with React 15.3.0 and higher.
Read more >How to define propTypes for a Component that only passes ...
3 Answers 3 · your first spread is not necessary : Parent.propTypes = { p0: PropTypes.string.isRequired ...Child. · in that case, you can...
Read more >react propTypes
PropTypes exports a range of validators that can be used to make sure the data you receive is valid. In this example, we're...
Read more >How to use the react-select.propTypes function in react ... - Snyk
node, value: PropTypes.any, }) ), // react-select knows this as multi, but for standardization // and compatibility we use multiple multiple ...
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
Would you mind sharing which libraries this is? I think that the correct course is to send PRs to them ☺️
Hey @mo22, I like your workaround. On which file are you adding this ?