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.jsdoes not match the corresponding path on diskreact.
Same for Title.js.
Any help would greatly appreciated.
\React\index.jsdoesn't match the corresponding path on diskreactReactin the path. Also when you seenode_modulesbeing looked into, you know that the import statement doesn't start with./,../...