File tree Expand file tree Collapse file tree 1 file changed +15
-6
lines changed
compose/neurosynth-frontend/src/hooks/metaAnalyses Expand file tree Collapse file tree 1 file changed +15
-6
lines changed Original file line number Diff line number Diff line change @@ -2,20 +2,29 @@ import { useQuery } from 'react-query';
22import API from 'utils/api' ;
33
44const useGetMetaAnalysesByIds = ( metaAnalysisIds : string [ ] | undefined ) => {
5- return useQuery (
5+ const shouldFetch = metaAnalysisIds && metaAnalysisIds . length > 0 ;
6+
7+ const result = useQuery (
68 [ 'meta-analyses' , metaAnalysisIds ] ,
7- ( ) =>
8- API . NeurosynthServices . MetaAnalysisService . metaAnalysesGet (
9- false ,
10- metaAnalysisIds || [ ]
11- ) ,
9+ ( ) => API . NeurosynthServices . MetaAnalysisService . metaAnalysesGet ( false , metaAnalysisIds ) ,
1210 {
1311 select : ( axiosResponse ) => {
1412 const res = axiosResponse . data . results || [ ] ;
1513 return res ;
1614 } ,
15+ enabled : shouldFetch ,
1716 }
1817 ) ;
18+
19+ if ( ! shouldFetch ) {
20+ return {
21+ data : [ ] ,
22+ isLoading : false ,
23+ isError : false ,
24+ } ;
25+ }
26+
27+ return result ;
1928} ;
2029
2130export default useGetMetaAnalysesByIds ;
You can’t perform that action at this time.
0 commit comments