You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems like useFetch never fetches data if the depends is something like [''], but sets isLoading to false immediately, i.e. pretending like it finished loading, but just producing the value undefined. This means that if the value in the depends array is a string that might sometimes be empty, data might just happen to be undefined so any code that expects data to exist if isLoading is false fails.
Full component example:
import useFetch from "react-fetch-hook";
function App() {
const { isLoading, data } = useFetch("https://api.github.com/", {depends:['']});
console.log(data);
return (
<p>
{JSON.stringify(data)}
</p>
);
}
export default App;
I'm not sure if this is intended or not, but given that there are situations where depends might include a sometimes empty string, I assume not.
The text was updated successfully, but these errors were encountered:
It seems like
useFetch
never fetches data if thedepends
is something like['']
, but setsisLoading
to false immediately, i.e. pretending like it finished loading, but just producing the valueundefined
. This means that if the value in the depends array is a string that might sometimes be empty, data might just happen to be undefined so any code that expects data to exist ifisLoading
is false fails.Full component example:
I'm not sure if this is intended or not, but given that there are situations where depends might include a sometimes empty string, I assume not.
The text was updated successfully, but these errors were encountered: