Kshitij Karkera
Kshitij Karkera

Reputation: 33

Why am I not able to import the following File

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?

Upvotes: 0

Views: 50

Answers (3)

MRK
MRK

Reputation: 1

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

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

Upvotes: 0

PAUL
PAUL

Reputation: 95

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'

Upvotes: 1

PiFanatic
PiFanatic

Reputation: 243

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';

Upvotes: 4

Related Questions