invalid hook call error
Hi, using refine.dev (vite) I'm trying to "preload" data from UseList
In order to do that, i'm tryint to write something like the following:
export const BaseElementsList: React.FC<IResourceComponentsProps> = () => {
const [all_categories, set_all_categories] = useState([]);
useEffect(() => {
async function fetchCategories() {
const { data: categories_data } = await useList<ICourier, HttpError>({
resource: 'base-categories',
});
const data = await categories_data?.data ?? [];
console.log( data );
set_all_categories(data);
}
fetchCategories();
}, []);
but the problem is that i got the error:
ncaught (in promise) Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
what am i doing wrong ?
In order to do that, i'm tryint to write something like the following:
export const BaseElementsList: React.FC<IResourceComponentsProps> = () => {
const [all_categories, set_all_categories] = useState([]);
useEffect(() => {
async function fetchCategories() {
const { data: categories_data } = await useList<ICourier, HttpError>({
resource: 'base-categories',
});
const data = await categories_data?.data ?? [];
console.log( data );
set_all_categories(data);
}
fetchCategories();
}, []);
but the problem is that i got the error:
ncaught (in promise) Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
what am i doing wrong ?
