use-http icon indicating copy to clipboard operation
use-http copied to clipboard

Fetch is called in spite of conditional variables are undefined

Open fkrafi opened this issue 4 years ago • 1 comments

Describe the bug Fetch is called in spite of conditional variable value is undefined

⚠️ Make a Codesandbox ⚠️

const {data} = useFetch(`/api/product/${id}`, {}, [id]);

Expected behavior Fetch shouldn't call the api when the conditional variables are undefined

fkrafi avatar Nov 04 '21 20:11 fkrafi

  1. you can just do useFetch(`api/product/${id}`, [id])
  2. this is a feature that would need to be implemented. I'm open to it. Submit a PR. I think the best way to do this would be to check if the dependency is undefined.

iamthesiz avatar Nov 07 '21 04:11 iamthesiz