I have a scenario where I need to update the iconName of a TabBarItem dynamically triggered during a user's interaction. I'm binding the name to a state based value to handle the update, however, the icon never changes. Here's my TabBarItem...
This function gets called inside componentWillReceiveProps(), however, as you can see it's basing its icon decision on this.props rather than a parameter or state.
I modified this by making updateIconSources take a props param. This is set to this.props in componentDidMount(), and nextProps in componetWillReceiveProps().
I tested the code and I'm now getting my desired result. Do you see any issues with this approach, and if not, would you accept a PR to incorporate this fix in the master code?
I have a scenario where I need to update the
iconName
of a TabBarItem dynamically triggered during a user's interaction. I'm binding the name to a state based value to handle the update, however, the icon never changes. Here's my TabBarItem...I dug into the node modules a little and found where the package is generating the icons based on props.
./lib/create-icon-set.js
This function gets called inside
componentWillReceiveProps()
, however, as you can see it's basing its icon decision onthis.props
rather than a parameter or state.I modified this by making
updateIconSources
take aprops
param. This is set tothis.props
incomponentDidMount()
, andnextProps
incomponetWillReceiveProps()
.I tested the code and I'm now getting my desired result. Do you see any issues with this approach, and if not, would you accept a PR to incorporate this fix in the master code?
Thanks!