Suggestion for accessing useQuery data
Context:
We are looking forward to migrate our async data handling layer of useContext + useReducer to react-query.
Currently we are in react v17 which means we have use react-query v4
We have an page which has header section (with high level info) and side tabs. Each tab will have multiple api calls (both parallel and dependent ones) and also multiple components which might only interest in specific data from specific api.
Idea is to fetch all api data in the root of the specific tab's parent which handles both loading and error scenario and then let child component access data without
One of the concern is type of data having
1. Going ahead with
Concern: The quality of the code.
2. using
Concern: We can't use this as we are at react-query v4 and also not sure does it has any pitfalls
We are looking forward to migrate our async data handling layer of useContext + useReducer to react-query.
Currently we are in react v17 which means we have use react-query v4
We have an page which has header section (with high level info) and side tabs. Each tab will have multiple api calls (both parallel and dependent ones) and also multiple components which might only interest in specific data from specific api.
Idea is to fetch all api data in the root of the specific tab's parent which handles both loading and error scenario and then let child component access data without
prob drilling and using select to only re-render on specific data change.One of the concern is type of data having
TData | undefined which forces us to ! . I was looking over internet for different options, these are something i found or came up with1. Going ahead with
! Concern: The quality of the code.
2. using
useSuspenseQuery to access in child components and parent to use useQuery for initial fetching. So we can handle api specific loading and error scenarios in parent and child can access data without concern. Concern: We can't use this as we are at react-query v4 and also not sure does it has any pitfalls