-
Notifications
You must be signed in to change notification settings - Fork 94
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
Remove propTypes #86
Comments
Great question. For people who use typescript, then the types are great. However, any developers who use this library in a non-typescript project need PropTypes to ensure that React stops them from passing in invalid props. I'm not sure how libraries that support web handle this use case, maybe you could see how they do type enforcement for non-typescript projects and let me know? |
@SteffeyDev asked me to weigh in here. I only use TypeScript, so I’m not sure, but this might be relevant to necolas/react-native-web#1684 |
Just updated my comment with the correct link. |
Not sure if I missed it, does that issue relate to PropTypes at all? |
Oh I see, this only relates to proptypes, not flow types, sorry got them mixed up since I don’t use either. |
@SteffeyDev I ran into the same problem as this issue with All you have to do is conditionally import This was the solution in import { View, Platform } from 'react-native'
const viewPropTypes =
typeof document !== 'undefined' || Platform.OS === 'web'
? PropTypes.shape({ style: PropTypes.object })
: require('react-native').ViewPropTypes || View.propTypes |
Ah very cool, I'll add this in and see if it works |
To please TS, you might need to make the web type |
Actually TS has a problem with |
Wix included that in their calendar library. I've never used prop types so I just copied that part over. |
Interesting. Don't think I need that either. |
Ok, this is done in the latest release, thanks for finding a good solution! |
Is your feature request related to a problem? Please describe.
I am currently trying to run the library on
react-native-web
. I know that the library is not officially supported on web, but would be nice to make it work. I will be doing some changes on my own fork, but wanted to use this thread as a platform to discuss a few things.react-native-web
has unspoortedViewPropTypes
as of 0.12. Therefore, I get the following error:Caused by the following lines:
Describe the solution you'd like
First I want to ask you why is
PropTypes
used in this repo while there is already great TypeScript implementation. If we get rid of PropTypes, it will work onreact-native-web
too. I will work on further improvements to make this library work on web, but I think it would be the first step.I would be happy if you could inform me why you choose to opt in for PropTypes.
Thanks in advance!
The text was updated successfully, but these errors were encountered: