score:0

Accepted answer

you are breaking the rule of hooks when you call it from any place other than the top level of a react component.

useeffect takes a callback function, and you are calling your hook from that. it is a problem.

i found this skip option in usequery which helps you call usequery conditionally.

 useeffect(() => {
    const { loading, error, data } = 
    usequery(get_mortgage_journey, {
      variables: { id: insuranceid },
      skip : (!insuranceid)
    });
  }, [insuranceid]);

any time insuranceid changes your callback runs, so it is run after mount once and then on subsequent changes.


Related Query

More Query from same tag