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

Unable to override `getFlag` or provide own flag assets #37

Open davidgoli opened 6 years ago

davidgoli commented 6 years ago

The documentation mentions a getFlag function, but subclassing the component & overriding it doesn't do anything. This is because the render method doesn't call getFlag, instead inlining the implementation:

          <Image
            source={Flags.get(iso2)}
            style={[styles.flag, this.props.flagStyle]}
            onPress={this.onPressFlag}
          />

We should change this to:

          <Image
            source={this.getFlag(iso2)}
            style={[styles.flag, this.props.flagStyle]}
            onPress={this.onPressFlag}
          />

or, better yet, convert this into a prop that can be passed in without subclassing.