score:4

Accepted answer

you are returning an array from your custom hook, so when destructuring the custom hook the order matters. to avoid such problems you can change this part in your custom hook from:

return [totalshowninvoices, handlelazyload];

to:

return {totalshowninvoices, handlelazyload};

then you can destructure it as follows and the order wouldnt matter:

const {handlelazyload, totalshowninvoices} = useloadinvoices(
    1,
    totalinvoices,
  );

score:1

the order matters when you destructure on array try

const [totalshowninvoices,handlelazyload] = useloadinvoices(
    1,
    totalinvoices,
  );

Related Query

More Query from same tag