Can't use any other variable names besides 'isLoading' and 'data'?`
JakeHadley opened this issue · 2 comments
JakeHadley commented
Is there a way to make it so I can use multiple useFetch hooks in the same file? Right now I get undefined for either variable that is different than 'isLoading' and 'data'. Is that on purpose?
ilyalesik commented
Of course, you can call multiple useFetch
in the same file/component. For example, you can just assign useFetch result to a variable without object destructuring:
const result1 = useFetch(...);
const result2 = useFetch(...);
...
result1.data;
result1.isLoading;
result2.data;
result2.isLoading;
or you can use object destructuring with passing custom variable names:
const {data: data1, isLoading: isLoading1} = useFetch(...);
const {data: data2, isLoading: isLoading2} = useFetch(...);
...
data1;
isLoading1;
data2;
isLoading2;
ilyalesik commented
I added the Multiple requests section.