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.

Timing bug with Suspense render results in `TypeError: Cannot set property '0' of null.`

See original GitHub issue

The app crash I’m seeing originates from here and surfaced as TypeError: Cannot set property '0' of null.

This was discovered during an application reworking to use preact rather than react. The bug does not repro with react.

Reproduction

CodeSandbox available here Minimal repo showing the issue is available here

Steps to reproduce

Force a re-render of a component hosting the <Suspense /> element before the initial fallback has rendered. In the minimal repro and my case, this was happening because something was being calculated and put into state during componentDidMount.

Suspense thinks it needs to render the fallback and detach the lazy component, however, because of the external re-render, there are no children in the vnode

Expected Behavior

Either the lazy is rerun, or the fallback is rendered.

Actual Behavior

The app crashes with TypeError: Cannot set property '0' of null.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:7
  • Comments:12 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
davidrhoderickcommented, Jul 27, 2021

This shouldn’t be closed (or maybe a new issue should be made) because as of 10.5.14, I get a t.__H is null error. When I downgrade to 10.5.4 as per @imgalli suggests, it goes away.

3reactions
iMakedonskycommented, Mar 22, 2021

@rdalmas there were a couple of issues with suspense.

  1. multiple lazy children inside suspense with preact/compat is causing one such bug. Fixed by wrapping only one lazy child inside a Suspense.
  2. There is a problem with components triggering onClick callbacks after being unmounted. Fixed by:
import { options } from 'preact';
options.debounceRendering = setTimeout;
  1. There are hydrate issues if you’re using ssr/prerendering. Resolved by using preact-iso.lazy/hydrate instead of regular lazy/hydrate
Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: Cannot set property '$render' of null - Stack Overflow
I got a TypeError: Cannot set property '$render' of null because I didn't set the model in some of the components. So, how...
Read more >
Suspense for Data Fetching (Experimental) - React
Approach 1: Fetch-on-Render (not using Suspense). A common way to fetch data in React apps today is to use an effect: // In...
Read more >
Documentation - SolidJS · Reactive Javascript Library
A declarative, efficient and flexible JavaScript library for building user interfaces.
Read more >
uncaught typeerror: cannot read properties of undefined (reading ...
You.com is an ad-free, private search engine that you control. Customize search results with 150 apps alongside web results. Access a zero-trace private ......
Read more >
React Hooks cheat sheet: Best practices with examples
Your browser can't play this video. ... Pass this reference as a property to new components to reduce rendering time.
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