Skip to content
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

How could a click event be implemented for the Flag? #4

Open
DenisTis opened this issue Nov 26, 2017 · 3 comments
Open

How could a click event be implemented for the Flag? #4

DenisTis opened this issue Nov 26, 2017 · 3 comments

Comments

@DenisTis
Copy link

No description provided.

@Buthrakaur
Copy link

I tried to achieve this too, but got errors when I just wrapped the Flag component inside TouchableOpacity to attach onPress event handler. The easiest but little bit dirty solution I came up with is just omit the Flag component and build your own:

import * as allFlags from 'react-native-flags/flags/flat/64'
...
<TouchableOpacity onPress={() => console.log(countryCode)}>
   <Image source={allFlags[countryCode] || allFlags.unknown} style={{ width: 64, height: 64 }} />
</TouchableOpacity>

@Buthrakaur
Copy link

Buthrakaur commented Nov 29, 2017

I just submitted PR to support onPress event in the Flag component #5

@DenisTis
Copy link
Author

DenisTis commented Nov 30, 2017

Thank you for the proposal, I was able to implement it in the meantime:

          <TouchableOpacity onPress={this.onFlagClick.bind(this, 'de')}>
            <Flag style={styles.flagToolbar} code="DE" size={48} />
          </TouchableOpacity>

But I like your way too and probably will switch to it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants