thegamenicorus / react-native-phone-input

Phone input box for React Native
https://www.npmjs.com/package/react-native-phone-input
MIT License
394 stars 447 forks source link

StyleSheet not supported #35

Closed davidgoli closed 5 years ago

davidgoli commented 6 years ago

I'm using ReactNative's StyleSheet to build styles, https://facebook.github.io/react-native/docs/stylesheet.html, which convert style objects into numerical ids that are used to look up the style from a global stylesheet. When using with this library, the styles are passed along just fine, but I get a warning: Warning: Failed prop type: Invalid prop 'textStyle' of type 'number' supplied to 'PhoneInput', expected 'object'.

This should be a fairly trivial fix, just updating the PropTypes to expect a number or an object should do the trick and get rid of the warning.

emjayschoen commented 6 years ago

This should also allow an array of styles e.g. textStyle={[Styles.textStyle, Styles.customStyle]}, which gives me the warning: Warning: Failed prop type: Invalid prop 'textStyle' of type 'array' supplied to 'PhoneInput', expected 'object'

alorr10 commented 6 years ago

Using this line as the PropType for style and textStyle is working for me:

PropTypes.oneOfType([ PropTypes.object, PropTypes.number, PropTypes.arrayOf(PropTypes.object), PropTypes.arrayOf(PropTypes.number), ]),