Johan Jönsson
Johan Jönsson

Reputation: 569

Import from nested components ReactJS

Okay so i really thought this would be simple or at least able to find similar problem by searching google but haven't found anything that help.

So i got two files one in the path

/src/components/menu/header/InformationHeader

and one in

/src/components/menu/sections/section_components/PromotionComponent

what i want to do is import InformationHeader into PromotionComponent but i cant seem to find a way how i tried

import { InformationHeader } from "../menu/header/InformationHeader";
import { InformationHeader } from "../header/InformationHeader";

and with all different combination of dots but nothing find it. I dont want to use an absolute path for it either with my username and all. I know there must be a simple solution for this but just cant find any answer.

Upvotes: 0

Views: 958

Answers (1)

Arup Rakshit
Arup Rakshit

Reputation: 118261

Ok you need to go up 2 folders..

import { InformationHeader } from "../../header/InformationHeader";

You are now in..

/src/components/menu/sections/section_components/PromotionComponent

so, now ../../ means you are now

/src/components/menu/

Upvotes: 1

Related Questions