onPress prop not working for Android
See original GitHub issueIssue Description
onPress prop not working for Android. Press a message bubble and attached function does not run.
Steps to Reproduce / Code Snippets
<GiftedChat
messages={this.formatMessagesFromRedux()}
onSend={messages => this.onSend(messages)}
onLongPress={(context, message) =>
this.onLongPressMsg(context, message)
}
onPress={(context, message) => {
Alert.alert('Bubble pressed');
}}
user={{name: this.props.myNameText, _id: this.props.myUserId}}
renderBubble={this.renderBubble}
showUserAvatar={true}
renderAvatar={props => {
const avatarProps = props.currentMessage;
if (avatarProps.user.avatar) {
return (
<Avatar
rounded
source={{uri: avatarProps.user.avatar}}
size="large"
/>
);
}
return null;
}}
/>
Expected Results
Alert is triggered
Additional Information
- Nodejs version: 10.16
- React version: 16.13.1
- React Native version: 0.63.3
- react-native-gifted-chat version: 0.16.3
- Platform(s) (iOS, Android, or both?): Android (havent checked ios)
- TypeScript version: n/a
Issue Analytics
- State:
- Created 3 years ago
- Comments:18
Top Results From Across the Web
React Native: Text onPress not working on android
Your code seems perfectly right and works for me... Try reloading or reinstalling the app 2-3 times.. It should work.
Read more >Handling Touches - React Native
Pressing the button will call the "onPress" function, ... If you like, you can specify a "color" prop to change the color of...
Read more >React Native: View onPress does not work - iTecNote
I'm facing a weird problem. In my react native app, if I set onPress event to View it is not triggered but if...
Read more >React Native touchable vs. pressable components
npm start # --- or --- yarn start npx react-native run-android # --- or ... The style prop is not available for Button...
Read more >react-native-popover-view - npm
A well-tested, adaptable, lightweight <Popover> component for react-native with no dependencies. Tested and working on iOS and Android. May work ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Well i have solved this issue it took me almost an hour guys but we did it ’ so the solution is quite simple
Now at the same file under declaration of giftedChat at line no. 114 under static default props add the onPress event
Now under static prop types below add the onPress EVENT
Now we are ended with this file now open the bubble.js file at “node_modules\react-native-gifted-chat\lib\Bubble.js”
Add the above code in the constructor at bubble.js below this.onLongPre… like this way
then add in touchable without feedback like this way
onPress= {this.onPress}
Then under Bubble.defuault Props add
this way
Then under Bubble.PropTypes add onPress
this way
Now guys lets move to another file Bubble.d.ts at ‘‘node_modules\react-native-gifted-chat\lib\Bubble.d.ts’’
Add onPress underStatic defualt props
this way
now under static PropTypes add
this way
Now add
this way
Also not forget to add onPress under exporting interface
this way
Now lets move to another file Bubble.js.flow this is the last file in which we have to list a change in order to fix this issue
add the
this way
It might be an issue with 16.3, try install the latest beta.