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.

Infinite render loop with Gatsby

See original GitHub issue

Subject of the issue

Hey,

I’ve posted this https://github.com/gatsbyjs/gatsby/issues/20942 too but the issue is likely caused here as it doesn’t happen with normal gatsby components.

Changing anything in the index.mdx in your example here once it’s running in the browser causes an infinite render loop in MDXProvider: https://github.com/mdx-js/mdx/tree/master/examples/syntax-highlighting

Here’s a repro but it’s essentially the same as your example with a couple of unnecessary things like unify-ui removed, same issue happens in either: https://github.com/DominicTobias/mdx-infinite-render-loop

Your environment

  • OS: MacOS Catalina
  • Packages: Latest Gatsby and your packages as per repo provided
  • Env: Latest yarn, latest Node LTS (v12)

Steps to reproduce

Repro: https://github.com/DominicTobias/mdx-infinite-render-loop

  1. yarn start
  2. Open up browser and observe this page: Screenshot 2020-01-30 at 18 41 53
  3. Go to index.mdx and change anything for example padding: "20px", -> padding: "21px",
  4. Observe infinite render loop in browser: Screenshot 2020-01-30 at 18 42 50

Issue does not happen if <LivePreview /> isn’t rendered

Expected behaviour

Should update the browser with changes without going into an infinite render loop causing CPU overload

Actual behaviour

Infinitely renders MDXProvider until the browser is refreshed

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
DominicTobiascommented, Oct 24, 2020

@farism did you figure it out? Haven’t used Gatsby for a while and set up a new doc site using gatsby-theme-apollo-docs. Was working fine for a while now it does it only on .mdx pages on changes and I have to browse to a .md page every time to stop it from infinitely reloading the page. Tried gatsby clean and fresh node_modules install etc.

Only does it on pages where I have live examples, so something about rendering a React component does it, or perhaps something to do with the fact the component I’m rendering is yarn linked.

0reactions
farismcommented, Apr 8, 2020

fwiw, this isn’t strangeness only reproducible by you @DominicTobias. Myself and a colleague are working on converting our doc site to gatsby and we are both encountering the same issue. I also see it on the codesandbox in chrome. Maybe we should reopen this?

Screen Shot 2020-04-07 at 11 27 00 PM
Read more comments on GitHub >

github_iconTop Results From Across the Web

Gatsby: Context update causes infinite render loop
The infinite loop happens when you go to page two (link at bottom of page one). What is the solution here, if I...
Read more >
Render a react component inside a loop with gatsby blog data ...
[Solved]-Render a react component inside a loop with gatsby blog data-Reactjs ... Infinite Loop caused when trying to fetch data and render it...
Read more >
The error "Too many re-renders. React limits the number of ...
React limits the number of renders to prevent an infinite loop occurs for multiple reasons - calling a function that sets the state...
Read more >
Build a Performant Infinite Scroll Image Gallery using Gatsby ...
In this post, we'll build a performant Infinite Scroll Image gallery using Gatsby.js, which is served over a CDN and uses Netlify functions...
Read more >
Gatsby Changelog | 5.3.0
When you use Gatsby Preview and your site errors out on rendering the HTML ... pindjur: fix(gatsby): prevent infinite loop in fast-refresh-overlay PR...
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