Doubt of navigation

Asked

Viewed 68 times

2

I created an RN project and within it I created a folder called screens.

Inside the folder screens created the files app.js and home.js

on index.android.js I only gave one: import App from './screens/app';

In the app js. I’m using the stackNavigator and gave a import Home from './home'

In the home js. used: import App from './App'

When running, it displays an error that cannot resolve the App module in home.js.

I’m a little lost in organizing the project into folders and importing and navigating between them.

2 answers

0


Post photo of your code so that the understanding of the problem is clear.

About navigation with Stacknavigator, I leave below an example on my github where I use this module objectively.

Link: Github

I hope I’ve helped.

Att,

Júlio Falbo

0

First, be careful of the way you are organizing your Mports. When importing home inside app and app inside home, you are causing a circular dependency

Second, you happen to be exporting something in those files of yours?

Remember that when using import algo from './arquivo' you need to make sure that this other file is exporting something. Example:

file1.js export default {}; -> file2.js import algo from './file1';

file1.js export { objeto1, objeto2 }; -> file2.js import { objeto1, objeto2 } from '.file1'

  • Thank you friend. Very good your explanation!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.