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.

[10.0.0-rc.0] Suspense's fallback not being unmounted when it should

See original GitHub issue

Hey.

I found a pretty weird issue on Suspense’s fallback implementation of Preact X. Here’s a small codesandbox with the issue (please navigate using the links on the demo to see the issue ocurring).

It’s pretty simple, actually: Basically, when using a Component as a fallback, the content rendered by that Component isn’t unmounted after Switch rendered the new page of the router.

Now, curiously, the issue is basically resolved when I use the content rendered by the Component directly as the fallback, OR when I use () => <Loading /> with the fallback. I assume there’s some flag on the component object that is making Preact to ignore it instead of just unmounting it, but as I don’t know many of the Preact internals I’ll post this issue here and hope for a solution.

Hope this helps to discover the cause of the issue. And keep the great work! 👍

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
fjorgemotacommented, Aug 4, 2019

Oh, okay, this makes sense.

Unfortunately, with that behavior the issue originally reported just…happens again. But okay, I’ll let the issue open anyway, and I’ll ignore the preact/debug issue for now.

Thanks for the reply anyway =)

1reaction
marvinhagemeistercommented, Aug 4, 2019

@fjorgemota preact/debug errors because () => <Loading /> is not a valid component instance. You’re passing the raw function instead.

// This is invalid
<div>{() => <Loading />}</div>

To pass Components around they need to be wrapped in h/createElement:

<div>{h(() => <Loading />)}</div>

// ... or via native jsx
const MyComponent = () => <Loading />;
<div><MyComponent /></div>
Read more comments on GitHub >

github_iconTop Results From Across the Web

A React component suspended while rendering, but no ...
A React component suspended while rendering, but no fallback UI was specified · Could you post your code? However from just the error...
Read more >
All You Need To Know About React Suspense - CopyCat Blog
We'll create a suspense fallback UI for our React app, this fallback UI will be rendered before our component is fully ready to...
Read more >
react - Awesome JS
React will automatically unmount and remount every component, whenever a component mounts for the first time, restoring the previous state on the second...
Read more >
preact: Versions - Openbase
Correct _nextDom pointer if it is being unmounted (#2889, ... Fix ref not being removed from props with jsx-runtime (#2840, ... 10.0.0-rc.3. 3...
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