-
Notifications
You must be signed in to change notification settings - Fork 2.3k
A change in tabs can produce display issues. #362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
I hate to use componentWillReceiveProps. It usually leads to bugs. Can you please provide code snippet to reproduce that bug. I hope there is a better solution |
|
This will trigger it. Note that you'll need a narrow screen. Any non-'Plus' iPhone in portrait should do it. |
|
@skv-headless Any thoughts on another way to solve this problem? |
|
Could you make showcase here https://github.com/skv-headless/react-native-scrollable-tab-view/blob/master/examples/FacebookTabsExample/DynamicExample.js so I will be able to check that it is working. |
…h between needing to scroll and not needing to scroll
|
I added a new example called ChangingScrollableTabsExample.js. If you remove my fix to ScrollableTabBar, you can see the bug in action. Just click back and forth between "long" and "short". |
|
@skv-headless Any thoughts now that you have a working test case? |
|
+1 |
|
@skv-headless Can this be merged? |
|
I tried this patch. I've updated |
|
|
||
| componentWillReceiveProps(nextProps) { | ||
| // If the tabs change, force the width of the tabs container to be recalculated | ||
| if (JSON.stringify(this.props.tabs) != JSON.stringify(nextProps.tabs) && this.state._containerWidth) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't you think that shallow comparison would be enough?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's why I used JSON.stringify. It's a poor man's deep equals. There are more precise ways to do it but they all take a lot more code and have slower performance.
Regardless, yes, I believe this should be sufficient to ensure that any change will trigger the state to update correctly.
…and forth between needing to scroll and not needing to scroll" This reverts commit a883cb8.
|
I reverted the example code and there are no conflicts with master so it should be good to merge. |
A change in tabs can produce display issues.
A change in tabs can produce display issues.
When there is a change in tabs via props in ScrollableTabBar, recalculate width.
There can be display issues when the tabs are changed after the ScrollableTabBar is rendered. The issues can be either tabs piling on top of each other instead of scrolling, or the tabs scroll as if there are far more tabs than there currently are. Either way, recalculating the width solves the issue.