-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
Screen loads twice when using TabNavigator #476
Comments
Try setting |
I can confirm that this doesn't happen in the beta 5 release though. Will stick with beta 5 until this is fixed. |
Also having the same problem & Happens in the examples project as well. |
Seems its introduced in the update to react-native-tabs in #366. I downgraded the lib to 0.0.55 and now it no longer mounts the component twice on initial load. |
I have the same issue |
cc: @satya164 |
Same issue. Using beta-6 |
Can any of you past the stack trace here? I'll try to fix it for the beta-7 for today's release. |
@grabbou there is no error thrown anywhere |
+1 for getting this into the beta 7 release !! |
We will try :)
…On Fri, Mar 3, 2017, 17:41 Des Preston ***@***.***> wrote:
+1 for getting this into the beta 7 release !!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#476 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACWcxuuAf9R_6zBTKw-ucrBd1tDChjWcks5riEKbgaJpZM4MLg_n>
.
|
Uhm, downgrading react-native-tabs to 0.0.55 fixed the problem to me. |
@arnsa how do I downgrade the react-native-tabs? I am using |
Looks like it's already reported here satya164/react-native-tab-view#160 |
Same issue for me, making it difficult to attach listeners to my components ... const Parks = StackNavigator({
Home: { screen: ParksScreen, },
Landmarks: { screen: LandmarksScreen },
}, {
headerMode: 'screen',
initialRouteName: 'Home',
navigationOptions: {
...stackNavOptions,
tabBar: {
label: 'Parks',
icon: ({ tintColor, focused }) => (
<Image
source={focused ? require('./src/images/ios/alphabet-filled.png') : require('./src/images/ios/alphabet.png')}
style={[styles.icon, { tintColor: tintColor }]}
/>
),
},
},
});
const Closest = StackNavigator({
Closest: { screen: ClosestScreen },
}, {
headerMode: 'screen',
navigationOptions: {
...stackNavOptions,
tabBar: {
label: 'Map',
icon: ({ tintColor, focused }) => (
<Image
source={focused ? require('./src/images/ios/map-filled.png') : require('./src/images/ios/map.png')}
style={[styles.icon, { tintColor: tintColor }]}
/>
),
}
},
})
const TabNav = TabNavigator({
Home: {
screen: Closest,
},
Parks: {
screen: Parks,
},
}, {
tabBarOptions: {
initialRouteName: 'Home',
activeTintColor: '#fff',
inactiveTintColor: '#bbb',
style: {
backgroundColor: colors.blue,
},
titleStyle: {
color: 'white',
}
},
}) |
Also stacktraces: 1st component mount
Second component mount
In case that helps... |
This issue is still happened, please update to |
* master: Docs: Update md links from coodoo's fork to react-community (react-navigation#750) Navigation Actions Doc (react-navigation#338) Update documentation regarding `DrawerNavigator` customisation (react-navigation#646) Fix flow in Navigation Playground (react-navigation#735) Adds documentation about forking and syncing repo (react-navigation#765) fix(docs): Fix incorrect style in TabNavigator sample (react-navigation#734) correction of a few documentation typo (react-navigation#563) Fix typo in docs for getComponentForRouteName (react-navigation#714) Drawer sidebar description (react-navigation#617) Remove 2nd return statement (react-navigation#661) Resolve gesture issues in CardStack Update dependencies Bump version number (react-navigation#650) Update react-native-tab-view. Fixes react-navigation#476 (react-navigation#641) Remove top margin from drawer view (react-navigation#642) Pass `transitionProps`, `prevTransitionProps` and `isModal` to custom `TransitionConfig` (react-navigation#565) Fix issue where initialRouteParams were not set (react-navigation#150)
I'm currently running into this issue with 1.0.0-beta.9. My initial screen is a StackNavigator and the initial route of that stack is loaded twice, one on top of the other. |
I solved this problem with setting |
Thanks @NachtRitter but that isn't solving it for me. |
same as @udfalkso 1.0.0-beta.11 I am using redux and my reducer is exactly the same as the doc example. It seems this might be a misunderstanding of how to route to nested navigators. In the case below, it looks like it constructs and mounts a component for each route in the array of routes. I would think it would only instantiate the last one, maybe this is what
I created the initialState by doing:
Should the initialState instead be?:
|
Interesting @chrismcleod . I'm also using redux. This is how I'm generating my initial state.
|
@udfalkso |
+1 |
+1 |
+1 |
1 similar comment
+1 |
I have a StackNavigator nested a DrawerNavigator. The DrawerNavigator is mounted three time |
I was facing the same problem, I just found a simple solution, in my case MyApp is an StackNavigator which includes a TabNavigator and StackNavigator, the problem came up when I wanted to navigate from the Home screen in Main to Results screen in Purchase, so Results screen was double mounted, I solved this when I set Results as the name for my screen Purchase in MyApp, as you can see it's the same name of the initialRouteName in Purchase, so It appears that you have to use the same name of the initialRouteName on a StackNavigator as the name of the screen in another StackNavigator, I leave an example code that right now It's working for me.
|
For some reason, when you open a screen in a modal StackNavigator, it pushes twice. I don't think this is the actual solution, but it does solve the problem for me for now. I'll need more time to dig into this some more. See this related issue for more: react-navigation#476 (comment)
Having the same issue for stacknavigator that loads the first screen twice, and you can see that the same screen get flashed twice. I don't know how to solve this, even the most simpliest example from the playground also produce the same results here somehow. Using
Downgrading to 1.0.0-beta.9 fixed the issue... |
+1 |
Solved this by naming everything down the tree by the same name as per @rubancar 's post:
for me my first main screen is my |
For some reason, when you open a screen in a modal StackNavigator, it pushes twice. I don't think this is the actual solution, but it does solve the problem for me for now. I'll need more time to dig into this some more. See this related issue for more: react-navigation#476 (comment)
This issue still exist with last version 1.0.0-beta.19 when using Redux and TabNavigator. componentWillMount is called twice |
still existing version in my case. I solved this problem using custom router. in
skip second action like this.
please change
I am sorry that English is awkward..... |
@luisfuertes 's fixs works for me, thanks change from
to
and could prevent multiple mount calls for me |
@satya164 Here is a repro: https://snack.expo.io/BJLIk4-Qz |
I have the same problem in beta-22 ... TabNavigator -> StackNavigator -> StackNavigator (mount twice) |
@rubancar solution works for me. |
Screen loads twice when using TabNavigator react-navigation#476
Repro code: https://snack.expo.io/BJLIk4-Qz Navigation structure:
Problem: MyScreen1 loads twice Possible cause: Possible solutions:
I think the inner action (Navigate to MyScreen1) is adding the screen for the second time in stack. initialAction should be probably just:
because I'm asking MyTabNavigator's router which action do I need to go to MyStackNavigator, not to MyScreen1. Other solution for given code would be to just use NavigationActions.navigate instead of MyTabNavigator.router.getActionForPathAndParams: Or just |
who can help me fix this issue? |
@mlazari is def. right. Using a sort of "empty" action for your initial state can stop this issue from happening. This seems like the cleanest way to do it.
Should the redux docs be updated to reflect this? |
Just upgraded to |
I have upgraded the react native to 1.2.1 and the issue was fixed. |
|
yay thanks |
given that this is resolved i will lock the issue. if you run into any other bugs please create a new issue. thanks! |
When using the TabNavigator the initial screen is loaded twice for some reason. This can be seen by adding an Alert or console.log in componentDidMount. I've replicated this in the SimpleTabs and StacksInTabs example. The SimpleStack example doesn't load twice.
const MyNavScreen = ({ navigation, banner }) => { Alert.alert(banner); return ( <ScrollView style={styles.container}> ....... </ScrollView> ); }
The text was updated successfully, but these errors were encountered: