incredible-moccasinI
Refine3y ago
17 replies
incredible-moccasin

Invalid hook call. Hooks can only be called inside of the body of a function component

hello, i got this error

Invalid hook call. Hooks can only be called inside of the body of a function component

the function is called by a click event on a button

const doExternalCall = () => {

const apiUrl = useApiUrl();

console.log( apiUrl );

const { data: customData, isLoading: customIsLoading } = useCustom<PostUniqueCheckResponse>({
url: ${apiUrl}/strapi-chat,
method: "get",
/*
config: {
headers: {
"x-custom-header": "foo-bar",
},
query: {
title: "Foo bar",
},
},
*/
});

console.log( customData );

};

what's wrong?
Was this page helpful?