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

🛠️ Replace useDispatch with useQuery/request #6316

Open
20 of 22 tasks
Tracked by #6058
rithviknishad opened this issue Sep 21, 2023 · 0 comments
Open
20 of 22 tasks
Tracked by #6058

🛠️ Replace useDispatch with useQuery/request #6316

rithviknishad opened this issue Sep 21, 2023 · 0 comments
Labels

Comments

@rithviknishad
Copy link
Member

rithviknishad commented Sep 21, 2023

❕ Do not assign this EPIC to yourself. Sub-issues specified below can be assigned to yourself.

Currently, we are using useDispatch to dispatch actions through fireRequest. We need to migrate this to use useQuery (for performing GET requests on component mount) and request to perform API calls of other methods (such as form submissions, etc.)

📖 References for the request and useQuery data fetching utilities

Tasks

Feel free to split these individual tasks further into multiple sub-tasks/PRs if the refactor is large. It will be easier to do the refactor, QA testing, and code review.

Steps to follow

  1. Perform a global search with from "react-redux" and specify the corresponding files to include regex as shown
image
  1. In all of the files in the search results, you'll have to remove the usage of useDispatch (and corresponding actions that are dispatched) and replace it with useQuery and request appropriately.

  2. All of the existing routes are available at src/Redux/api.tsx which can be passed to the useQuery/request directly.

  3. For each route that is being used, ensure the response type is also present. If not, you'll have to add it.

Example:

config: {
  path: "/config.json",
  noAuth: true,
  TRes: Res<IConfig>(),  // 👈 Add this
},
  1. Delete the relevant no longer used actions from actions.tsx. (Ensure the action is not used outside the scope of the migration too)

  2. You'll also need to add cypress tests if existing cypress tests do not cover pages/components where the replacements are being done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: In Progress
Development

No branches or pull requests

1 participant