简体   繁体   中英

How to import a file from another folder in react?

tsx file in below path

app/frontend/src/pages/main/_form/output.tsx

now i want to import this file "output.tsx" into "Parent.tsx" file which is in below path

app/frontend/src/pages/Lists/_form/formSteps/Step1/Parent.tsx

how can i import output.tsx file in Parent.tsx file

i have tried below

import {something] from '../../output.tsx';

but the path seems to be errorneous. could someone help me out with this. thanks


The common root is pages which is 4 levels up from Parent.tsx , so below should work fine

../../../../main/_form/output.tsx

Also if its a default import use like this

import Output from '../../../../main/_form/output.tsx ;

use like that import {something} from '../../output.tsx';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM