New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use of window object in my component causing error after working at first #14336
Comments
Hi @martinpsz! Sorry to hear you're running into an issue. To help us best begin debugging the underlying cause, it is incredibly helpful if you're able to create a minimal reproduction. This is a simplified example of the issue that makes it clear and obvious what the issue is and how we can begin to debug it. If you're up for it, we'd very much appreciate if you could provide a minimal reproduction and we'll be able to take another look. Thanks for using Gatsby! 💜 |
Hello. I had the same issue with using window and trying to run gatsby build. Quick fix use windowGlobal variable that's checks if window is available :) then use it whenever you need to refer to window object :) ` const windowGlobal = typeof window !== 'undefined' && window; class Nav extends Component {
} export default Nav; Link to the issue #309 :) |
Hiya! This issue has gone quiet. Spooky quiet. 👻 We get a lot of issues, so we currently close issues after 30 days of inactivity. It’s been at least 20 days since the last update here. If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open! As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing! Thanks for being a part of the Gatsby community! 💪💜 |
Hey again! It’s been 30 days since anything happened on this issue, so our friendly neighborhood robot (that’s me!) is going to close it. Please keep in mind that I’m only a robot, so if I’ve closed this issue in error, I’m As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing! Thanks again for being part of the Gatsby community! |
I am trying to use a window event to add a background to my nav on scroll. At first, it worked. Now, I am not able to build and getting the following error in the console:
"Uncaught TypeError: doc.documentElement.doScroll is not a function at ready.js: 19 at ready.js: 7 at Object../node_modules/@mikaelkristiansson/domready.ready.js..."
I have tried, as some have suggested in regards to using window objects in Gatsby, to move my scroll function arguments to the ComponentDidMount lifecycle method. That has not fixed the issue. I have seen that there is an issue in using the window object in SSGs like Gatsby but I am not understanding how to work around this issue.
This is the relevant parts of my code on this:
and the JSX code which uses the scrolled value in state to apply the background:
I should note that I am only seeing this issue in Chrome when I have dev tools open refreshing the page. This is even happening in incognito mode. I am not seeing the same issue in Firefox. Both browsers are at the latest version.
The text was updated successfully, but these errors were encountered: