For example, if I am building a Menu component, I would like to be able to use it like this: import Menu, from 'components/Menu' In addition, the index could also include named exports. The default export from this file is the component itself. A component should be as self-contained as possible (but not more so).Ī typical component directory might look something like this: ├── components As such, they can be treated as mini-projects in and of themselves. What to include in the component directoryĬomponents are the building blocks of every React app. But what is equally important (and often overlooked) is the question of how to best structure components. Usually, when we talk about file structure, the discussion focuses on the project as a whole. The freedom we have when using un-opinionated tools like React comes with a great deal of responsibility. Creating an adequate and scalable file structure for front end projects can be challenging.
0 Comments
Leave a Reply. |