ThomasFindlay/react-the-road-to-enterprise

Question regarding routing on scalable-project-architecture

Closed this issue · 2 comments

Hi Thomas,

I love your book and it has taught me a lot! There is one thing that I can't find in your book regarding scalable project architecture if it's routing on specific views folder of encapsulated components and business logic. In this example, you wrote in the book.

src
|-- views
    |-- products
         |-- ViewProduct
              |-- components
                   |-- ProductImage.tsx
                   |-- ProductDetails.tsx
              |-- views
                   |-- BasicProductDetails.tsx
                   |-- AdvancedProductDetails.tsx
              |-- ViewProduct.tsx
              

What should the naming for the nested routing of the products be and where should the specific file of nested routing for the product folder live? I just saw an example you wrote was app.js, but as you know having every kind of route inside an app.js would be really hard to maintain at an enterprise level, so it would make more sense split up routed components.

I hope you can reply to me back! Thanks, Thomas!

Hey @KoichaDev. I'm happy to hear you love the book. Re routing, you can nest the Routes component.

Here's an example stackblitz - https://stackblitz.com/edit/vitejs-vite-du3b51?file=src/views/products/ViewProduct/ViewProduct.jsx.

I hope that helps.

Thanks for the reply! This is definitely helpful! Cheers!