1

I am new to React. I have create new react app using following command.

create-react-app app-name --scripts-version custom-react-scripts-version

Inside src folder of that app i have created 2 new folders say Grid and Title and created files Grid.js and Title.js in respected folder.

Grid.js

import React from 'React';

export default class Grid extends React.Component {
    render() {
        return (
            <div>
                <h1>Grid</h1>
            </div>
        );
    }
}

Title.js

import React from 'React';

const Title = () =>  {
    return (
        <div>
            <h1>Title</h1>
        </div>
    );
}

export default Title;

Now, i try to import both into App.js file it won't.

import Title from './Title/Title';
import Grid from './Grid/Grid';

It shows following error.

Failed to compile.

./src/Grid/Grid.js Module not found: D:\ReactAppCSS\node_modules\React\index.js does not match the corresponding path on disk react.

Same for Title.js.

Any help would greatly appreciated.

3
  • Look what the error says - \React\index.js doesn't match the corresponding path on disk react Commented Oct 19, 2018 at 13:44
  • Yeah, Path is perfect i checked many times Commented Oct 19, 2018 at 13:52
  • Oh it was a comment regarding the capitalization of React in the path. Also when you see node_modules being looked into, you know that the import statement doesn't start with ./, ../... Commented Oct 19, 2018 at 13:56

1 Answer 1

7
import React from 'react'

react is the package name!

Sign up to request clarification or add additional context in comments.

Comments

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.