Home > Enterprise >  Why am I not able to import the following File
Why am I not able to import the following File

Time:08-12

This is my src directory -

enter image description here

And while importing the last file (StateProvider.js) in Product.js, this is the error I get while importing StateProvider -

enter image description here

My import statement from Product.js-

enter image description here

Can anyone guide me, why my import is not working?

CodePudding user response:

The error occurs because StateProvider.js is not in the same directory as Product.js. You have to specify the import statement like this:

import StateProvider from '../../StateProvider';

CodePudding user response:

Probably 2 errors.

First, If you export the default file you're good to go.

export default StateProvider

Second is if you are on the correct directory.

it shouild be

import StateProvider from '../../StateProvider'

CodePudding user response:

import StateProvider from '../../StateProvider'

I also recommend using "Auto Import" extension if you working with Visual Studio Code.

  • Related