Component inside Tab won't re-render when a prop changes its value.
See original GitHub issueIssue type
I’m submitting a …
- bug report
- feature request
Issue description
Current behavior:
When a component prop inside <Tab />
is updated via the redux store, the component doesn’t re-render.
Expected behavior: The component should re-render when the prop changes.
Steps to reproduce:
Add component inside a <Tab />
Related code:
<TabView
selectedIndex={this.state.selectedIndex}
onSelect={this.handleTabSelect}
style={[styles.tabView]}
tabBarStyle={[styles.tabBarView]}
indicatorStyle={[styles.tabIndicator]}
>
<Tab title="Tab 1" titleStyle={[styles.tabTitle, this.state.selectedIndex === 0 && styles.tabTitleSelected]}>
...
</Tab>
<Tab title="Tab 2" titleStyle={[styles.tabTitle, this.state.selectedIndex === 1 && styles.tabTitleSelected]}>
...
</Tab>
<Tab title="Tab 3" titleStyle={[styles.tabTitle, this.state.selectedIndex === 2 && styles.tabTitleSelected]}>
...
</Tab>
<Tab title="Tab 4" titleStyle={[styles.tabTitle, this.state.selectedIndex === 3 && styles.tabTitleSelected]}>
<MyCustomComponent propFromRedux={propFromRedux} />
</Tab>
</TabView>
The MyCustomComponent
won’t re-render when propFromRedux
change its value.
To make sure that the problem is not in MyCustomComponent
, I’ve moved it outside the <TabView />
and when the propFromRedux
changed, the component re-rendered.
Other information:
OS, device, package version
OS: iOS 12
Device: iPhone Xs
Package version: 4.0.5
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (2 by maintainers)
Top Results From Across the Web
Component rerenders when state has not changed on the ...
Save this question. Show activity on this post. I have a tabs component that changes state every time a different tab is clicked....
Read more >When does React re-render components? - Felix Gerschau
Want to see re-rendering in action? React DevTools lets you highlight renders under Components -> View Settings -> Highlight updates when ...
Read more >5 Ways to Avoid React Component Re-Renderings
1. Memoization using useMemo() and UseCallback() Hooks. Memoization enables your code to re-render components only if there's a change in the props. With...
Read more >Learn how to force react components to rerender without ...
You can change the value of the key prop, and it will make React unmount and re-mount the component again, and go through...
Read more >useMemo - React Docs
A list of dependencies including every value within your component that's ... a re-render is slow, you can tell List to skip re-rendering...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks! I was just testing this on your playground and it worked.
Keep up the great work!
@NBoychev sorry for the misunderstanding. I just used the “master” version of the framework, so everything worked for me 😃