Issue
I have touchable in react native, inside touchable I have image and on press like this
<TouchableHighlight >
<Image style={styles.imagestyle}
source={require('./ic_action_name.png')} />
onPress={() => this.moveToAddNewCustomer()}>
</TouchableHighlight>
When I tried to run the app, I got this error
React.Childeren.only expected to receive a single React element child
How to fix this?
Solution
You need to do it like this:
<TouchableHighlight onPress={() => this.moveToAddNewCustomer()}>
<Image style={styles.imagestyle} source={require('./ic_action_name.png')} />
</TouchableHighlight>
or
<TouchableOpacity onPress={()=>this.moveToAddNewCustomer()}>
<Image style={styles.imagestyle} source={require('./ic_action_name.png')} />
</TouchableOpacity>
Answered By - Venkatesh Somu
Answer Checked By - Katrina (JavaFixing Volunteer)