react-hooks-axios
react-hooks-axios copied to clipboard
using global "window" causing server-side to blow up
I use the next.js framework and like other SSR frameworks, builds the app in node. I'm getting the error I'm pasting below from "I have no idea where" but I think it might be inside react-hooks-axios using the window object. Is that possible. Feel free to close right away if this isn't the case and sorry for the trouble.
ReferenceError: window is not defined
at Object.
Hi, I have no idea for this, there's no DOM-related things used in this package, it seems like the feature of axios, but there's no more information to dig out the reason.
Thanks
I had the same problem while working with Gatsby. Checking for window before declaring useAxios worked. I'm building a custom hook, so it looks like this:
if (typeof window !== 'undefined') {
const useAxios = require('@use-hooks/axios');
return useAxios.default({
// ...
})
}
For some reason, I had to call useAxios.default instead of just useAxios.
@dlbnco reopened and look for more feedback
same problem
It may be related with this https://github.com/axios/axios/issues/244
same problem