question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Console warnings on load.

See original GitHub issue

Hello, This project is fantastic!

I have one gripe, and I’m happy to say it’s a small one. I’m running giscus as a component in a Gatsby (React SSR) project. It seems to work perfectly, but there is a warning that comes up when a new post is loaded with giscus at the bottom:

[iFrameSizer][Host page: iFrameResizer0] [iFrame requested init] IFrame(iFrameResizer0) not found

This warning multiplies when new posts are loaded (e.g. the 1st post I click will have none, the 2nd will have one, the 3rd will have two and the 4th will have four).

I believe this means the following line in client.js is being run before the child exists, but I am unsure:

loadScript('https://cdnjs.cloudflare.com/ajax/libs/iframe-resizer/4.3.1/iframeResizer.min.js', function () {
    return iFrameResize({ checkOrigin: [giscusOrigin], resizeFrom: 'child' });
});

Maybe it’s my implementation? Here is the TSX component I’ve written for handling the script:

import React from "react"

type DataProps = {
  className?: string
}

const Comment: React.FC<DataProps> = ({ className }) => {
  // Used for https://giscus.app/
  // https://creativcoder.dev/how-to-add-github-utterances-blog
  const commentBox = React.createRef<HTMLInputElement>()

  React.useEffect(() => {
    const scriptEl = document.createElement("script")
    scriptEl.async = true
    scriptEl.src = "https://giscus.app/client.js"
    scriptEl.setAttribute("data-repo", "<STUFF>")
    scriptEl.setAttribute("data-repo-id", "<STUFF>")
    scriptEl.setAttribute("data-category", "Announcements")
    scriptEl.setAttribute("data-category-id", "<STUFF>")
    scriptEl.setAttribute("data-mapping", "title")
    scriptEl.setAttribute("data-reactions-enabled", "1")
    scriptEl.setAttribute("data-theme", "preferred_color_scheme")
    scriptEl.setAttribute("crossorigin", "anonymous")
    if (commentBox && commentBox.current) {
      while (commentBox.current.firstChild) 
		if (commentBox.current.lastChild) 
			commentBox.current.removeChild(commentBox.current.lastChild)
      commentBox.current.appendChild(scriptEl)
    }
  })

  return (<div ref={commentBox} className={`comments ${className}`} />)
}

export default Comment

Because these warnings don’t affect functionally, this should be a low-priority issue.

Any help with this would be appreciated, thank you!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
ceiphrcommented, Jul 6, 2021

@laymonage it’s working, but there is one issue. I will report it on https://github.com/giscus/react-giscus.

1reaction
laymonagecommented, Jul 5, 2021

@ceiphr Yeah, I forgot about the ref, it shouldn’t even be needed. I’ve published an npm package, see react-giscus. It’s my first package on npm, so please let me know if you find any issues. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

console.warn() - Web APIs | MDN
The console.warn() method outputs a warning message to the Web console.
Read more >
Hide errors and warnings from console - javascript
A dirty way to hide all Javascript console warnings is by overriding the console object's warn method: console.warn = () => {};.
Read more >
Debugging in JavaScript: Reading Console Errors
Console shows an error and a warning. At the time this lesson was written, there was an error and a warning. The warning...
Read more >
JavaScript console.warn() Method - W3Schools
The warn() method writes a warning to the console. Note. When testing console methods, be sure to have the console view visible. Press...
Read more >
Google Search Console is Sending Warnings About Slow ...
Google is sending warnings to webmasters via Search Console, notifying them of slow-loading pages.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found