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

TouchableWithoutFeedback children #87

Open
mmarovich opened this issue Jul 23, 2017 · 0 comments
Open

TouchableWithoutFeedback children #87

mmarovich opened this issue Jul 23, 2017 · 0 comments

Comments

@mmarovich
Copy link

mmarovich commented Jul 23, 2017

This isn't really an issue with the code itself, just the first example that was used. My apologies if this has already been covered. In the example:

function renderOption(option, selected, onSelect, index){
    const style = selected ? { fontWeight: 'bold'} : {};

    return (
      <TouchableWithoutFeedback onPress={onSelect} key={index}>
        <Text style={style}>{option}</Text>
      </TouchableWithoutFeedback>
    );
  }

will throw the warning: TouchableWithoutFeedback does not work well with Text Children. Changing it to:

renderOption(option, selected, onSelect, index) {
        const style = selected ? { fontWeight: 'bold' } : {};

        return (
            <TouchableWithoutFeedback onPress={onSelect} key={index}>
                <View>
                    <Text style={style}>{option}</Text>
                </View>
            </TouchableWithoutFeedback>
        );
    }

fixes it.

Also, the optionContainerStyle prop doesn't appear to pass effectively. But if I pass the styles traditionally using the above added , it will work:

renderOption(option, selected, onSelect, index) {
        const style = selected ? { fontWeight: 'bold' } : {};

        return (
            <TouchableWithoutFeedback onPress={onSelect} key={index}>
                <View style={styles.optionContainer}>
                    <Text style={style}>{option}</Text>
                </View>
            </TouchableWithoutFeedback>
        );
    }
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

1 participant