Skip to content
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

setRoot causes Error: Invariant Violation: "Screen" has not been registered. #11

Open
JohnnyHuangTW opened this issue Mar 8, 2023 · 1 comment

Comments

@JohnnyHuangTW
Copy link

Hi, @kanzitelli

I am now using rnn-screens 0.3.1 and facing some strange problems.

I have a main screen that goes to different feature screens and I am using screens.N.setRoot(Root(screens.get("screenName"))) to navigate to different feautre screens.

Originally I have a component named "Login" and it worked fine. But when I changed the name to "LoginScreen" and navigate to login screen by using setRoot, this error shows up "Invariant Violation: "LoginScreen" has not been registered. This can happen if: ....".

It only happens when setRoot, push and show work fine. I am wondering if I am using setRoot wrong.

Here's the Login component

const Login = ({ componentId, type, passProps }) => 
	
	return <View>...</View>
}

export default Login

// error occurs after I changed Login to LoginScreen

here's my screens object in screens/index.js

export const screens = generateRNNScreens(
	{
		Main: {
			component: MainScreen,
			options: {
				topBar: {
					...withTitle('Main')
				}
			}
		},
		Sample: {
			component: SampleScreen,
			options: {
				topBar: {
					...withTitle('Sample')
				}
			}
		},
		Login: {
			component: LoginScreen,
			options: {
				topBar: {
					visible: false
				}
			}
		},
		Feature1: {
			component: Feature1Screen,
			options: {
				topBar: {
					...withTitle('Feature1 Screen')
				}
			}
		}
	},
	[withGestureHandler, withServices]
)

Thanks for your time and help in advance!

@kanzitelli
Copy link
Owner

Hey @JohnnyHuangTW!

I could see that error before here #8. I am not sure if it's the same, but it would great if you provide more code (with actual names and navigation part) to fully understand the picture.

Also, rnn-screens will be merged to Navio and be better maintained and supported.

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

No branches or pull requests

2 participants