Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Do I need to put a text in App.tsx or do I have to create a separate file?

I have a question for a React file (I’ve just started).

Do I have to put text in App.tsx for example:
<h1>Hello World!</h1>,
or do I have to create a separate file like Text.tsx and import it into App.tsx?

Thanks for your help!

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I’ve looked everywhere on the Internet, but I haven’t found a site that talks about this subject.

>Solution :

In my opinion, it’s best to add your text in index.tsx or .jsx. In any case, it’s important to know that later on, your app.tsx won’t receive text, but rather libraries to assist you in working or retrieving information about your project. I’m currently thinking about Redux or React Router. Personally, I never touch app.tsx because I use _document.tsx for Next.js (https://nextjs.org/docs/pages/building-your-application/routing/custom-document). Alternatively, for vanilla React, I suggest you take a look at this link: https://blog.floxus.co/best-practice-to-manage-folder-structure-for-reactjs.

So, in conclusion, for an example or testing, you can put the information in app.tsx, but in the future, for larger projects, I think that won’t work.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading