winoteam / react-router-navigation

⛵️ A complete navigation library for React Native, React DOM and React Router
MIT License
499 stars 49 forks source link

Rerendering TabBarBottom #78

Open ifalldev opened 6 years ago

ifalldev commented 6 years ago

Do you want to request a feature or report a bug? I think its kind both.

What is the current behavior? If the current behavior is a bug, please provide necessary steps for reproduction of this issue, or better the reduced test case (without any external dependencies, if possible).

  1. I have an app with bottom navigation and one of the tabs has a badge with a count of notifications

  2. The notifications is fetch when the app starts but the component have to wait the server response

  3. The response arrive and change the redux state and the component props as well

  4. The badge doesn't shows up because the navigation is still on same index and the TabBarBottom doesn't rerender

  5. Changing the active tab the TabBarBottom rerender and the badge shows up

What is the expected behavior? The TabBarBottom rerender even with the same index navigation if I want

To work in my scenario I commented out those lines:

shouldComponentUpdate(nextProps: Props) {
    const { index } = this.props.navigationState
    const { index: nextIndex } = nextProps.navigationState
    return index !== nextIndex
 }

Environment (include versions). Did this work in previous versions?

I can work on a PR if that feature is good to the package as whole.

simonbuerger commented 6 years ago

You could put mapStateToProps on the component inside the renderTabIcon function. Should bypass your issue