Can I use useRef() for the purpose to memoize an object from a custom hook? Because without that when if I use that returned object from the hook as a useEffect dependency I get an infinity loop of requests.
Example of my code that I use now:
const apiHook = useRef({})
apiHook.current = useRequest(
'http://someapi',
{
onSuccess: (data) => {
console.log(data)
}
}
)
useEffect(() => {
apiHook.current.run()
}, [])