I have been playing around with ReactJS for approximately two weeks now and i find it interesting. However, i have come across something new: How to put files into folders. This brings out a number of questions:
- What is the importance of putting files into a structure [In React] ?
- Is there a particular approach that you currently use that eases the process building and accessing React Apps? Thanks
Top comments (8)
Thanks Mohammed..Do you mind elaborating further?
this is well thought. do you have it on a gist so I could fork it? thanks.
I usually split UI from logic, and the logic is split according to the entities you have.
Thanks..I have bookmarked this...
What I've seen in big projects with redux so far, and fits good in my brain is something like this:
File structure is crucial to get right, and by right I mean logical and consistent. A bad file structure will make ongoing development miserable, slow and likely buggy.
My preferred method, is to have containers and components.
Components are things like buttons, lists, input boxes etc, often just wrapped and styled html elements.
Containers are pages and groupings of components, think nav bars and forms.
In a react sense these are still components, but from a dev perspective they separate them as they would likely be tested differently.
I also like keeping the structure of my
src
directory for mytest
directory. Although I am liking having the tests sit local to what they are testing more and more.Im sure people will have opinions on how i like to structure things, it is a very opinionated thing. I know I can make improvements, and next project I will. The important thing is to learn what works and what doesn't. Changing a file structure after creation is a difficult thing to do successfully.
Thanks George..This structure seems logical and easy to understand..I mean in the event of a bug..It is easy to locate it..In the event of any question, I won't hesitate contacting you..Cheers..