-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(web): adopt TanStack Query for state management (#1439)
Trello: https://trello.com/c/8u1WOJz4/3723-8-agama-ui-adopt-a-state-management-solution Agama's UI state management could be better. For that reason, and after evaluating a few alternatives (see the list of considered alternatives), we decided to adopt [Tanstack Query (former React Query)](https://tanstack.com/query/v5). ## Why TanStack query * It offers a mechanism (based on promises) to fetch/update the state. * It is not limited to the client state: it works great with the server state, too. * It takes care of caching, re-fetching, error handling, etc. * It is a mature, well-documented and widely known project. * Plays nicely with [React Router](https://reactrouter.com/), although a [TanStack Router](https://tanstack.com/router/latest) project exits. ## What is included in this PR There is quite some work to do so let's consider this pull request as the first step in this path. It introduces the following changes: - Add TanStack query as a dependency. - Replace `L10Provider` with a queries-based approach, including data mutation. Check [queries/l10n.js](https://github.com/openSUSE/agama/blob/react-query/web/src/queries/l10n.js) if you are curious. - Re-enable L10nPage tests (and add other tests). - Use React Router loaders to make sure data is loaded before the components are rendered. ## Considered Alternatives - [Redux](https://react-redux.js.org/) - [Jotai](https://jotai.org/) - [Zustand](https://docs.pmnd.rs/zustand/getting-started/introduction) - [Tanstack Query (former React Query)](https://tanstack.com/query/v5) - [Recoil](https://recoiljs.org/) We had a look at others but did not consider them at all.
- Loading branch information
Showing
31 changed files
with
743 additions
and
1,106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.