2

I am trying to learn to use react native and am following along with this YouTube tutorial. I have encountered an error stating the following, "Unable to resolve the module ... from ...: could not resolve ... as a file nor folder." I am fairly certain that the file path used is correct and I have followed the video very closely, and it appears to work in this video. Any help with this would be greatly appreciated as I am unfamiliar with using components in react.

index.js

import React, {Component} from 'react';
import { AppRegistry, Text, View } from 'react-native';
import App from './App';

import Component1 from './app/components/Component1/Component1';

export default class myapp extends Component {
  render() {
    return(

      <View>
        <Component1 />
      </View>

    );
  }
  constructor() {
    super();
  }
}

AppRegistry.registerComponent('myapp', () => myapp);

component1.js

import React, {Component} from 'react';
import { AppRegistry, Text, View } from 'react-native';
import App from './App';

export default class Component1 extends Component {
  render() {
    return(

      <View>
        <Text>This is Component 1.</Text>
      </View>

    );
  }
  constructor() {
    super();
  }
}

AppRegistry.registerComponent('Component1', () => Component1);

enter image description here enter image description here

1
  • 1
    component1.js has c small. Commented Oct 12, 2017 at 20:31

1 Answer 1

5

Try this path to your component

import Component1 from './app/components/Component1/component1';
Sign up to request clarification or add additional context in comments.

3 Comments

Hey, thanks for the quick response. I copied the code you provided directly in and did not solve the issue. Instead it is now returning the path as in the last statement of the error as, "Users/spencermiller/Desktop/Coding/Apps/myapp/components/Component1/App".
After looking it over again, I see that in order to make the code match I had to actually change the name of the component1.js file to Component1.js! Thanks for the help once again.
@Spencer M. Glad to help

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.