React: global state, context providers and app services separation #1978
stalniy
started this conversation in
Contribution RFC
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
This document proposes a strategy for how we use React Providers, Jotai, React Query, and Services in the Console frontend projects.
The goal is to reduce unnecessary re-renders, and establish clear boundaries for application-wide state, remote data, and services.
Motivation
Right now we have 22 providers wrapping the deploy-web app.
Each provider is a potential trigger for re-rendering the entire application whenever its state changes.
This creates unnecessary overhead, makes reasoning about state harder, makes unit testing harder, and increases the risk of performance issues.
We need a clear convention for:
Proposal
1. Use React Providers only for static values
Examples:
ThemeProvider)ServicesProvider)2. Use Jotai for application-wide state
✅ Benefit: Unlike React Context, updating one atom does not re-render the entire app — only components using that atom are updated. This also gives us a possibility to serialize jotai store and store in localStorage
Examples:
3. Use React Query for remote data
Examples:
4. Extract service logic into services
ServicesProvider.This keeps our architecture clean:
Beta Was this translation helpful? Give feedback.
All reactions