Closed mbrookson closed 4 years ago
Hi, thanks for the feedback! This should not be too hard to fix, just make sure than AbortController exists before using it should do the trick. I'm currently stuck at the hospital (16m free fall at climbing 😅) so I can't really take this issue now, but if you want to open a PR, I can review it 😉
Hi. I'm working on a fix but want to test locally with my Gatsby build to make sure it's working, however I'm getting an error when running yarn build
or yarn watch
. Any ideas?
Never had this locally, very strange and no ideas, sorry...
All I did was fork master, run yarn
and run yarn build
🙁
Node version maybe? This is running well on my computer and Travis... So... I don't really know what to think
Yeah it was node version. I was running the latest version. Downgrading to LTS version resolved it.
Here's the issue if you're interested! https://github.com/nodejs/node/issues/32107
Fixed! Thanks to @mbrookson 😘
The problem I've recently ported my personal site into a Gatsby application to try it out. I love restful-react, but I've hit an issue where the Gatsby static HTML build fails due to restful-react hooks depending on AbortController at the point when the hook is run, rather than when the HTTP request is made. Gatsby suggest any interactions with browser APIs be run inside a
useEffect
so that they run when the browser binds to React, rather than at build time. However, this is happing in a hook so I cannot move it to inside auseEffect
as it breaks the rules of hooks!Potential solution Haven't looked at the restful-react source code yet but it seems like creating an instance of AbortController is being done prematurely and should be done at the time of calling the
mutate
function exposed byuseMutate
, for example, rather than whenuseMutate
is first run.Alternative solutions
Example usage
Link to Gatsby docs https://www.gatsbyjs.org/docs/debugging-html-builds/
Output of Gatsby build error