The recommended folder structure of the application is to separate features from components. This enforces the idea that a feature is not tied to the UI, they can be implemented in isolation and used across UI components, no matter what page they are on.
Applications typically has navigation to different pages, where a page reflects a feature. The index.tsx of the pages folder would hold the router.
pages/index.tsx
import React from "react";
import { BrowserRouter as Router, Switch, Route } from "react-router-dom";
import { DashboardPage } from './dashboard'
import { ProjectPage } from './project'
export const Pages = () => (
<Router>
<Switch>
<Route exact path="/">
<DashboardPage />
</Route>
<Route path="/projects/:id">
<ProjectPage />
</Route>
</Switch>
</Router>
);
Each page has its own index.tsx file mapping any router params to the feature. This is an important separation to not make features dependent on a router.
Any children components of the feature now has access to the feature itself. You might compose a layout with multiple features in this file.
The application logic is expressed as provider components. Read more in features on how to define a feature. Any related utilities and tests is defined within the same folder.
This folder contains all the environment effectsthe application needs to operate. Each environment effect has its own folder where it defines how to operate in the different environments, typically test and browser.
The main index.tsx file contains the provider for exposing the environment to the features.