Current I have the following custom hook:
function useSecurity() {
const { getAccessTokenSilently } = useAuth0()
const getAccessToken = async () => {
return await getAccessTokenSilently()
}
const getAuthHeader = async () => {
return { Authorization: `Bearer ${await getAccessToken()}` }
}
return { getAuthHeader }
}
In a page where I use it I have:
const { getAuthHeader } = useSecurity()
useEffect(() => {
async function fetchData() {
...
}
}
fetchData()
}, [getAuthHeader])
This code causes infinite loop page load, I assume because getAuthHeader is a coroutine. I know I can don't have to include it in the deps (and ignore eslint warnings), but is there a way I can include it in the deps and not trigger the infinite loop?