Erik L
Erik L

Reputation: 195

need assistance in accessing a component

I am new to programming and react, I have a component called App, on App [line 16] I am trying to import a component called Gallery by typing import Gallery from "/Gallery" but that is not working, here is a screenshot

Can't import Gallery Component

Upvotes: 0

Views: 42

Answers (3)

jpatiaga
jpatiaga

Reputation: 352

This is not specific to React, it is ES6 module import.

App is not in the same folder as Gallery so you need to specify the path. Try import Gallery from './Components/Gallery'

Check http://exploringjs.com/es6/ch_modules.html for more information.

Upvotes: 2

Matthew Herbst
Matthew Herbst

Reputation: 32003

Your path is wrong. It should be ./Components/Gallery since it's in the same folder as the current component. /Gallery goes all the way to the root.

Upvotes: 2

sjdm
sjdm

Reputation: 589

Your Gallery file is inside the Components folder, therefore you need to give the exact path to the component, in this case './Components/Gallery'

Upvotes: 4

Related Questions