всем привет!
использую кастомный хук в Нексте, выдает ошибку:
Invalid hook call. Hooks can only be called inside of the body of a function component
import React, { useState, useEffect } from "react";
const useFetch = (url, options) => {
console.log("useFetch called");
const [response, setResponse] = useState(null);
useEffect(() => {
const doFetch = async () => {
const res = await fetch(url, options);
const json = await res.json();
setResponse(json);
};
doFetch();
}, []);
return response;
};
export default useFetch;
что не так делаю?