Why adding another second element to the view causes an error "React.Children.only expected to receive a single React element child."
I have my own component that the apollo client uses to invoke the graphQL endpoint to receive data. If I only have visualization of the view, it works, however, when I add tangible highlighting, I get an error. Can I have at most one root element in a view or make it a view with compound elements? I tried adding it as Buttonwhich also missed another error. However, adding text looks fine.
class Games extends Component {
constructor(props) {
super(props);
}
render() {
const { loading, allGames } = this.props.data;
if (loading) {
return <Text>Loading</Text>;
} else if (allGames) {
return (
<View style={styles.outer}>
//adding this touchable highlight causes the error
<TouchableHighlight>Get More</TouchableHighlight>
{ allGames.map(game => (
<View key={game.id} style={styles.wrapper}>
<Text style={styles.header}>{game.title}</Text>
</View>
))}
</View>
);
}
return (
<Text>No results</Text>
);
}
}
Games.propTypes = {
data: PropTypes.shape({
loading: PropTypes.bool.isRequired,
allGames: PropTypes.array,
}).isRequired,
};