React-native-router-flux: Show badge number on Tab at Tabbar

Created on 10 Nov 2016  路  2Comments  路  Source: aksonov/react-native-router-flux

Version

Tell us which versions you are using:

  • react-native-router-flux v3.30.1
  • react-native v0.35.0

Expected behaviour

This is actual a question instead of an issue, and I searched closed issues but I cant find an answer.
Basically I am wondering if scene (when used as tab) supports badge number (I think the answer is no.)
From my understanding, even if badge number is supported (or custom compoent), it won't get updated with state changed since router cant be re-rendered via redux connect.

So, is my only option to make my own tabbar component and wire actions for each tab, and only use router to render my first tab?

Thanks in advance.

Most helpful comment

We (my company) actually implemented it..
You need to connect your icon component to redux and it works great..

import YourTabIcon from './YourTabIcon';

const mapStateToProps = state => {return {badgeCount: state.notifications.count};};
const ConnectedYourTabIcon = connect(mapStateToProps)(YourTabIcon);
// ...
<Scene key="yourTab" icon={ConnectedYourTabIcon} hideNavBar>

and in YourTabIcon you can implement your badge :)

All 2 comments

We (my company) actually implemented it..
You need to connect your icon component to redux and it works great..

import YourTabIcon from './YourTabIcon';

const mapStateToProps = state => {return {badgeCount: state.notifications.count};};
const ConnectedYourTabIcon = connect(mapStateToProps)(YourTabIcon);
// ...
<Scene key="yourTab" icon={ConnectedYourTabIcon} hideNavBar>

and in YourTabIcon you can implement your badge :)

@atlanteh Thank you! Work like a charm!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fgrs picture fgrs  路  3Comments

xnog picture xnog  路  3Comments

kirankalyan5 picture kirankalyan5  路  3Comments

willmcclellan picture willmcclellan  路  3Comments

wootwoot1234 picture wootwoot1234  路  3Comments