This is my src directory -
And while importing the last file (StateProvider.js) in Product.js, this is the error I get while importing StateProvider -
My import statement from Product.js-
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.