Skip to content

Fix TabViewAnimated screenProps caveat#862

Merged
satya164 merged 2 commits intoreact-navigation:masterfrom
stochris:master
Mar 30, 2017
Merged

Fix TabViewAnimated screenProps caveat#862
satya164 merged 2 commits intoreact-navigation:masterfrom
stochris:master

Conversation

@stochris
Copy link

Please provide enough information so that others can review your pull request:
Accordin do the react-native-tab-view, TabViewAnimated is a pure component, and as such, will not be rerendered unless it's props change.
This prevents rerenders when screenProps on TabNavigator change, and as such, is a major limitation when using TabNavigator.
The proposed solution is to pass the screenProps to the TabViewAnimated, even if does not use this in any way.
Any change to the screenProps of TabNavigator will trigger a rerender in TabViewAnimated.

Explain the motivation for making this change. What existing problem does the pull request solve?

Allows using screenProps with TabNavigator

Prefer small pull requests. These are much easier to review and more likely to get merged. Make sure the PR does only one thing, otherwise split it.

Test plan (required)

Don't know how much this could be tested, since I've only added screenProps={this.props.screenProps} to the TabViewAnimated component.

Demonstrate the code is solid. Example: The exact commands you ran and their output, screenshots / videos if the pull request changes UI.

Make sure you test on both platforms if your change affects both platforms.

The code must pass tests and shouldn't add more Flow errors.

Code formatting

Look around. Match the style of the rest of the codebase.

@satya164
Copy link
Member

I'll merge this, but you should really just connect individual screens instead of passing data in screenProps.

@satya164 satya164 merged commit 05f0361 into react-navigation:master Mar 30, 2017
@stochris
Copy link
Author

stochris commented Mar 30, 2017

I encountered the problem when using GraphQL. Normally, I'd' just skip the screenProps, but in my case, I load some data when on app, then render navigator ( and pass it the recieved data )

lintonye added a commit to lintonye/react-navigation that referenced this pull request Apr 3, 2017
* master:
  Docs: Added clarification for header configuration (react-navigation#891)
  Fix gesturesEnabled regression (react-navigation#886)
  bump react-native-drawer-layout-polyfill (react-navigation#882)
  Fix rebase commands (react-navigation#870)
  Possibility to overwrite label's style if defined as string. (react-navigation#731)
  add example for DrawerNavigatorConfig (react-navigation#552)
  Workaround for screenProps in TabViewAnimated (react-navigation#862)
  Update Guide-Nested.md (react-navigation#813)
  remove ReactComponentWithPureRenderMixin (react-navigation#809)
sourcecode911 pushed a commit to sourcecode911/react-navigation that referenced this pull request Mar 9, 2020
bartlomiejbloniarz pushed a commit to bartlomiejbloniarz/react-navigation that referenced this pull request Jan 7, 2026
const { itemId } = route.params;
const { otherParam } = route.params;

can be combine into {itemId, otherParam}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants