Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: use react router loader to fetch data to eliminate the use of useEffect #283

Merged
merged 7 commits into from
Mar 10, 2024

Conversation

bjarneo
Copy link
Member

@bjarneo bjarneo commented Mar 10, 2024

This pull request includes major changes to the routing and data fetching in the client-side codebase, as well as a small change to the server-side settings controller. The changes mainly involve moving the data fetching logic from individual components to the router, and using the useLoaderData hook to access the fetched data in the components. This simplifies the components by removing unnecessary state and effect hooks related to data fetching, and centralizes the data fetching logic in the router.

Changes to the router:

  • src/client/routes.jsx: Added a loader prop to each Route component under the /account path. Each loader is an asynchronous function that imports and calls the appropriate API function to fetch the necessary data for the route.

Changes to components:

Change to server-side controller:

Copy link

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@bjarneo bjarneo merged commit b20c472 into main Mar 10, 2024
6 checks passed
@bjarneo bjarneo deleted the chore-fetch-router branch March 10, 2024 17:22
bjarneo added a commit that referenced this pull request Jun 8, 2024
…of useEffect (#283)

* refactor: get user from the route and not in use effect

* refactor: get user from the route and not in use effect

* refactor: get user from the route and not in use effect

* refactor: get user from the route and not in use effect

* refactor: get user from the route and not in use effect

* refactor: get user from the route and not in use effect

* fix: sonar lint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant