Skip to content

Two different icons for one tabBarItem #743

Answered by grahammendick
mHvNG asked this question in Q&A
Discussion options

You must be logged in to vote

Hi, you can control the active tab

const [tab, setTab] = useState(0);
<TabBar tab={tab} onChangeTab={setTab}>

Then use the active tab state to decide what image to show

<TabBarItem image={{uri: tab === 0 ? 'home_filled' ; 'home_outline'}}>

This is still asynchronous but it's faster.

Let me know if the delay is still noticeable because I'm thinking of accepting a function for the image prop

<TabBarItem image={selected => ({uri: selected ? 'home_filled' ; 'home_outline'})}>

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@see2ever
Comment options

Answer selected by grahammendick
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants