So I was wondering how you would import an component, or basically any data from another component with just import someComponent from 'another component'
.
Asked
Active
Viewed 24 times
0

Metgher Andrei
- 197
- 1
- 10
-
1You have to define this in your project configuration where you define "shortcuts" for certain files/folder. If you want more help, don't hesitate to publish a screenshot of your project architecture. – Tomus Sep 05 '22 at 17:09
-
Thanks Tom for commenting that, what do you want to see from my 'project architecture'? – Metgher Andrei Sep 06 '22 at 10:54
-
Sorry for my English I'm French ^^ I'm talking about the file/folder tree of your project. But the screenshot is not really necessary, just do you have a `jsconfig.json` or `tsconfig.json` file? – Tomus Sep 06 '22 at 19:07
-
Thanks Tom no problem your english is very good actually. I already fixed the problem where I created a index.js file in my folder with all the 'components' and exported them as default and just imported them in another component. ( I used absolute imports to make just a single 'component' import. But either way thanks Tom for wanting to help me. Cheers man – Metgher Andrei Sep 06 '22 at 19:36
-
Ok, indeed this is a good method for your case, well done! In the future if you want to be able to import files in any other file thanks to an alias, there is this post which could help you: https://stackoverflow.com/questions/63067555/how-to-make-an-import-shortcut-alias-in-create-react-app – Tomus Sep 06 '22 at 19:50