tabBarOnPress inside static 'navigationOptions' not working
See original GitHub issueWhat kind of Issue is this?
- () Bug Report
- () Question / Problem
- (x) Discussion / Feature Request
How are you using the Bottom Navigation?
- (x) I use the Bottom Navigation together with react-navigation; the Issue is not appearing when I’m using react-navigation’s TabBar instead.
- () I use the standalone version.
Expected behavior
I have added a tabBarOnPress callback function in the static navigationOptions, this function should run when the Tab is pressed. I would like to use the callback to scroll to top when the tab bar is pressed.
Actual behavior
The function is not called.
Additional description and resources
The tabBarOnPress was a new feature added to react-navigation so this might need a custom implementation in the bottom navigation component.
static navigationOptions = ({ screenProps }) => ({
tabBarLabel: 'Feed',
tabBarIcon: (
<Icon
size={24}
color={screenProps.theme.bottomNav.inactiveIcon}
name="view-agenda"
/>
),
tabBarOnPress: (scene, jumpToIndex) => {
console.warn(scene)
}
});
What did you do to find a solution?
I have read this whole issue in the react-navigation repo. https://github.com/react-community/react-navigation/pull/1335
Environment
- React Native versions: 0.50.0
- react-native-material-bottom-navigation version: 0.5.3
- react-navigation version: 1.0.0-beta.17
- I tested this with: Android
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
tabBarOnPress inside static 'navigationOptions' not working.
and inside the 'OverView' component I am passing the 'navigationOptions' statically as suggested in the Documentation. here is the snippet:.
Read more >react native - tabBarOnPress not working bottomTabNAvigator
I tried using tabBarOnPress in my third screen in static navigationOptions, but it does not seems to work. HEre is the snippets for...
Read more >Configuring the header bar - React Navigation
So let's jump in to configuring the header bar. ... A screen component can have a static property called navigationOptions which ... Thankfully,...
Read more >Hi, take a look at this. Modified from your snack example | by Jimmy ...
Modified from your snack example. I moved the SettingsScreen into a stack and now the tabBarOnPress inside SettingsScreen has stopped working..
Read more >Handle Tab changes in React Navigation v2 - ITNEXT
Approach #2: using tabBarOnPress() · static navigationOptions = () => { return { tabBarOnPress({ navigation, defaultHandler }) { · defaultHandler ...
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
I published this feature as v0.6.0 🎉
Please let me know if there should be any more issues with this
I published the fix as v0.6.1. 🎉
I’m getting to a point where a few features conflict each other, and it’s a bit tricky to implement it in a way so they don’t conflict each other. To my surprise, I couldn’t reproduce any errors or weird behaviors.
Let me know if something seems wrong.