2

I've been doing React for ~2 years, I've started learning React Native a few days ago and immediately ran into a wall.

I'm trying to import a simple .jsx file into my App.js:

import PostsPage from './pages/PostsPage/PostsPageContainer.jsx';

Here's the error I'm getting:

Unable to resolve ./pages/PostsPage/PostsPageContainer.jsx" from ".//App.js: could not resolve/Users/MyUser/Documents/app-name/pages/PostsPage/PostsPageContainer.jsx' as a file nor as a folder","name":"UnableToResolveError","type":"UnableToResolveError","errors":[{}]},"type":"bundling_error"}"

There's a huge thread on this error but it's all people trying to import outside modules. I'm trying to import a regular .jsx file which I'd created myself. I've double and triple-checked that the file does exist and it's spelled right. I've also tried restarting the packager and clearing cache.

I've used ‎create-react-native-app to create this app.

user2634633
  • 509
  • 8
  • 21

2 Answers2

2

For your file extensions in react-native, use .js instead of .jsx. The default extension is .js unless you want to disable that rule.

Onyekachi Ezeoke
  • 912
  • 7
  • 11
0

Here is an issue I had and solved by removing the hyphen from the folder name: https://github.com/bnovf/react-native-github-graphql-app/issues/15

I can see your file path has a .../app-name/.., change it to appname or appName and dont use underscore i.e app_name

I dont know the reason but that helped me.

Fatah
  • 2,184
  • 4
  • 18
  • 39