question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

tabBarOnPress inside static 'navigationOptions' not working

See original GitHub issue

What 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:closed
  • Created 6 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
timomehcommented, Nov 4, 2017

I published this feature as v0.6.0 🎉

Please let me know if there should be any more issues with this

0reactions
timomehcommented, Nov 5, 2017

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found