-
Notifications
You must be signed in to change notification settings - Fork 32
Usegetoptions and data lists to hooks using tanstack #1442
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
Usegetoptions and data lists to hooks using tanstack #1442
Conversation
…a-lists-to-hooks-using-tanstack
…https://github.com/Altinn/app-frontend-react into usegetoptions-and-data-lists-to-hooks-using-tanstack
… global state not being available. This should clean up and simplify the state in useAllOptions.tsx and fixes the problem.
…d yet, we saved a list of no nodes, meaning all options were loaded every time. This should delay the 'nodesFound' event until we have actually found nodes.
…e receipt page/archived task type
…tanstack # Conflicts: # src/queries/queries.ts
…ed mapped options after preselectedOptionIndex (so that they appear in summary)
…Type(). Only data tasks are expected to generate nodes, and for non-data tasks we should say we found no nodes, and there are thus no options to fetch.
…use infinite loading/spinner, as it just did (before we fixed it by checking the current task type)
@lassopicasso Tests pass! 🥳 Time to write a description here about the whole ordeal, and open up for review.. 😁 |
…ed by Percy, so as to make sure it's not flaky
… until it finds the value
SonarCloud Quality Gate failed.
|
Not sure what happened there with the Percy screenshots - the close button is now also shown on the receipt page for some reason, but it wasn't before. IMO, the close button should probably be shown there, so I think it's all OK. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Description
In this task @Magnusrm and I have collaborated to improve the functionality of two hooks,
useGetOptions
anduseDataLists
, in order to reduce their dependence on Redux states. Our primary objective was to implement Tanstack Queries for fetching data within components using these hooks. This change will also allow us to eliminate some redundant Saga code.I would like to extend a special thanks to @olemartinorg for his invaluable contributions and significant involvement in realizing this project! ❤️
I’ve tried to summarized of what this PR introduces, but there’s a possibility I may have overlooked certain points. So, if there’s anything unclear in the code, feel free to point it out.
Changes to useGetOptions
useGetOptionsQuery
, solely responsible for fetching options.useGetOptions
hook, expanding its functionality to include support for static options and options (source) from repeating groups.preselectedOptionIndex
and options changes from the components to the reusableuseGetOptions
hook. We also introduced new functionality inuseRemoveStaleValues
to retain options that still exists when options have changed.Changes to useDataLists
useGetDataListQuery
, solely responsible for fetching options.useDataLists
hook as there is for now no need for an intermediate layer between the component and useDataListQuery.These enhancements aim to streamline the use of these hooks and reduce their reliance on Redux states, ultimately improving the efficiency and maintainability of the codebase.
Unit and cypress tests
We’ve made significant updates to unit tests, addressing issues where they previously relied on options being available immediately without the need for fetching.
Furthermore, we have introduced new test cases to ensure everything works as planned, such as including handling options in dynamic scenarios (useRemoveStaleValues), resolved flakiness issues, and tested other behaviors that could result in failed tests following the implementation of Tanstack Query. These tests ensure the robustness of our code changes.
Related Issue(s)
useGetOptions()
and data lists to hooks using Tanstack Query without Redux #1294Verification/QA
kind/*
label to this PR for proper release notes grouping