mercredi 1 avril 2020

Should I extract ReactJs code to other files

I would like to ask you guys if I should extract React code to other files. As our components grow, we get a lot of specific code in the main .js file. How do you deal with this?

I myself separated what I guess (may be wrong/ actually I'm beggening with React and don't know exactly if it's true) are the main parts of a component's code. I would say then: - imports - state management - handlers - conditional rendering - the componet's body - styling

I usually extract the styles to another .js file (not using css for now), and it's pretty cool, but what about handlers, state management and conditonal rendering?

I gotta say, I'm tempted to do that! hahahahaha I've been working with Rails for a while and we do this kind of thing SOOO MUUUCH there.

Aucun commentaire:

Enregistrer un commentaire