The app structure ensures all components and services related to a particular feature are kept in a subdirectory of the features
directory.
Observe the directory structure for Authentication feature in features/auth
It contains the ProtectedRoute
component and web3Service
which extends the base API service defined in src/api.ts
by endpoint injection.
Global routing configuration is held in src/index.tsx
. Below is an example of a route definition
A protected route i.e a routed which requires a user's wallet connection should be within the parent ProtectedRoute
component route
Find more information about routing here.
This is as easy as creating a new folder in the features
directory that holds all the resources for that particular feature.
The directory structure requires that all components and services which are related to a particular feature be kept in a subdirectory of the features
directory.
Observe the directory structure for Authentication feature in features/auth
It contains the ProtectedRoute
component and web3Service
which extends the base API service defined in src/api.ts
by endpoint injection.
Some features require server-side state management which involves keeping the UI in sync with an external data source e.g REST/GraphQL API service, Smart Contract etc. We use RTK Query which is
a powerful data fetching and caching tool. It is designed to simplify common cases for loading data in a web application, eliminating the need to hand-write data fetching & caching logic yourself
All queries and mutations inject endpoints into the base API src/api.ts
web3Service.tsx
UI components access data and states thus,
Learn more about Redux Toolkit and RTK Query.