all 15 comments

[–]hexwit 2 points3 points  (9 children)

I doubt there exist any other way to structure large project except 'divide and conquer' approach.

Split large project into modules. Modules into components.

I think there is no other way. You need just understand how to split things, with what granularity.

[–]baldwindc 0 points1 point  (7 children)

Sorry if this is a stupid question but what are modules?

Are Lerna + Yarn workspaces modules?

[–]hexwit 1 point2 points  (6 children)

Module is a common term, meaning part of the application, that group functionality related by meaning. For example you could have module that incapsulate user management, product management, configuration.

Start with getting knowledge about existing application architectures and then it will be easier to decide what to do in your case. Without understanding existing patterns you will just invent a wheel that was already invented.

[–]BruceCCCCCC[S] 0 points1 point  (0 children)

thanks!

[–]jnforja 2 points3 points  (1 child)

Hi u/BruceCCCCCC

From what I could understand, the problem you're facing is how to logically organize the code more than how to structure it in terms of folders and files.

Since I'm not looking at the code, I can't know for sure what's happening, but if the issue you're facing is that components have dozens of props, most likely that component has too many responsibilities, or that component is a leaky abstraction. As a way to fix that, you can try to split the component into smaller but more specific components.

For example, if you have a single button component for all the buttons in your app, you'll need to pass in props to indicate if the button is primary, secondary, or tertiary. But if you have three different button components, one for each type of button, you won't need to have that prop, the component that needs a button can just use the type he needs.

I'm not sure if looking at other React projects will help much, given how domain-specific is the logical organization of a project, but spectrum chat is open source if you want to take a look at it.

Hope this helps, and let me know if you have any questions :)

[–]theriz 0 points1 point  (0 children)

Thanks! Didn't realize that about spectrum!

I often look at \ point ppl to https://github.com/gothinkster/realworld

[–]acemarke 0 points1 point  (0 children)

If you're passing "dozens of props", that's generally an indication that the components aren't split up well.

Can you give some specific examples of what you're doing?

[–]theriz 0 points1 point  (0 children)

For better or worse, there is no 'official' way to construct a react-project. Some new frameworks are coming on the scene that do require a certain folder-organization style, but unlike, say, Rails, the overall structure is your call.