In the above example, List component exports only List, but it also has the ListItem component, which is not exported. At this point, as our project is still quite small, I would do it like this: Instead of having all our code in one file, we can split these components into multiple files. Often it's better to use multiple files because eventually, that one file is not sufficient anymore. Sometimes it's OK to have multiple components in one file, especially if those components are tightly coupled to the main component. React projects usually start with an src/ folder and one src/App.tsx file with an App component.Īt some point, your app has more features, more lines, and you will need to make smaller standalone components: I decided to share how I have structured my projects lately. Structuring React applications into files and folders is an opinionated topic, because there is no right or wrong way to do it.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |