BetterTyped / hyper-fetch

⚡ Fetching and realtime data exchange framework.
https://hyperfetch.bettertyped.com/
Apache License 2.0
1.02k stars 27 forks source link

fetchOnMount option #64

Closed pmkod closed 1 year ago

pmkod commented 1 year ago

The fetchOnMount option on useFetch don't work correctly. I set the option to false but the request is sent const { data, success, error, refetch, setData } = useFetch( getSearchSuggestionRequest.setQueryParams({ q: value }), { fetchOnMount: false, } );

GerasNyx commented 1 year ago

Hi @pmkod - could you provide, by any chance, a bigger chunk of code showing how/where you use useFetch? Codesandbox with a reproducible behavior would be ideal.

prc5 commented 1 year ago

I think I know what's happening, you're probably looking for the disable: true option. fetchOnMount is only applicable for the cases when you have already fetched data and you don't really want to revalidate it in the background. I think we should change it's name to just that: fetchOnMount -> revalidate

pmkod commented 1 year ago

I think I know what's happening, you're probably looking for the disable: true option. fetchOnMount is only applicable for the cases when you have already fetched data and you don't really want to revalidate it in the background. I think we should change it's name to just that: fetchOnMount -> revalidate

Ahh okay, thanks