ilyalesik/react-fetch-hook

"isLoading" changes to true also if the "depends" field is false

dalborgo opened this issue · 1 comments

When the isValidMail variable is false the data is correctly set to undefined but the isLoading changes to true.

const isValidMail = !validator_email(orgEmail).error
const {isLoading, data} = useFetch(`https://satec.cynation.com/api/v1/accounts/search/org?api-key=8a0b7868-57c8-430e-95a9-de915ff2b7d8&email=${orgEmail}`,{
    depends: [isValidMail]
  })

DevTool log (isValidMail=false):

isLoading: false index.js:91
data: undefined index.js:92
isLoading: true index.js:91
data: undefined index.js:92
isLoading: false index.js:91
data: undefined

DevTool log (isValidMail=true):

isLoading: false index.js:91
data: undefined index.js:92
isLoading: true index.js:91
data: undefined index.js:92
isLoading: false index.js:91
data: 
Object { orgId: "2c5168a8-1b5b-474e-96f8-f62e9dd51231", orgName: "Example" }

Hi, @dalborgo. Thank you for the issue. I fixed it at 1.6.2 .