-
-
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
Circular Reference Issue in StackNavigator? #1396
Comments
One possible solution is to put all of your possible stack screens into one generic file called
Then you can define import { Stack } from './Stack';
export const InstructorProfileStack = StackNavigator({
...Stack
},
{
headerMode: 'screen',
navigationOptions: {
headerVisible: false
}
}); and do the same for An alternative approach (and probably better) is to wrap your two navigators in another navigator: export const StackWrapper = StackNavigator({
InstructorProfile: {
// routes
},
Courses: {
// routes
},
{ /* stackNavigatorConfig */ }
} |
Thanks for your response @matthamil , but I think it should be simpler than that implementation of just creating more and more navigators since we already defined the navigators we need. I think this
export const InstructorProfileStack = StackNavigator({
InstructorProfile: {
screen: InstructorProfile,
},
Schedule: {
screen: Schedule,
},
Courses: () => ({
screen: CoursesStack, // Circular Reference Function 1
}),
},
{
headerMode: 'screen',
navigationOptions: {
headerVisible: false
}
};
export const CoursesStack = StackNavigator({
Courses: {
screen: Courses,
},
StudentForm: {
screen: StudentForm,
},
InstructorProfile: () => ({
screen: InstructorProfileStack, // Circular Reference Function 2
}),
},
{
headerMode: 'screen',
navigationOptions: {
headerVisible: false
}
}); The I tried the above but it also doesn't work with this library. What's the cleanest solution? Is it possible to implement a simple, clean way to solve the |
This is currently undocumented, but you can do |
@satya164 I really thought that'll work: Courses: {
getScreen: () => CoursesStack, // Circular Reference Function 1
}, But it behaves the same way: It doesn't consider the |
Looks like a bug. It shouldn't try to validate this as declaration time as it's supposed to be lazy loaded. cc @ericvicenti |
bump @ericvicenti |
@skevy can this be looked at, it seems like an ignored bug? |
@MovingGifts There are currently 417 open issues and only so many maintainers :) it might take them a while until they can take actions to resolve this. They are always appreciative of PRs though. |
I don't think getScreen is the answer as the docs says
|
Yeah it doesn't really work. I know |
can someone who would like to see this issue resolved please create a new issue with a reproducible example on https://snack.expo.io or in a github repository, with a minimal amount of superfluous code? (please don't post your entire app, just a small one to reproduce the problem). thanks! |
InstructorProfileStack
should be able to navigate toCoursesStack
andCoursesStack
should be able to navigate toInstructorProfileStack
, each within their respectiveStackNavigator
stack.The issue is that
// Circular Reference 1
,CoursesStack
is not yet defined, but if I swap the order, the other one will not be defined. So how can we get them both to navigate correctly regardless of their defined order?The text was updated successfully, but these errors were encountered: