JSON_Derulo
JSON_Derulo

Reputation: 992

How to solve "Unable to resolve module..." error with react-native?

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

Upvotes: 2

Views: 10328

Answers (1)

lankovova
lankovova

Reputation: 1426

Try this path to your component

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

Upvotes: 5

Related Questions