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.

[Bug] Can't render without <Suspense />

See original GitHub issue

Reporting a bug?

When trying to create an app component per the documentation https://github.com/react-static/react-static/blob/master/docs/api.md#routes, it doesn’t work without a <React.Suspense fallback={<em>Loading...</em>}> component.

I get the following error:

An internal error occured!

Error: RoutesInner suspended while rendering, but no fallback UI was specified.

Add a <Suspense fallback=...> component higher in the tree to provide a loading indicator or placeholder to display.
    in RoutesInner
    in Unknown
    in Unknown (created by Context.Consumer)
    in withRouter()
    in Unknown (created by Routes)
    in Routes (at App.js:15)
    in Switch (at App.js:14)
    in div (at layout.js:11)
    in Layout (at App.js:13)
    in Router (created by BrowserRouter)
    in BrowserRouter
    in Unknown
    in Unknown (created by Root)
    in Catch (created by Root)
    in Root (at App.js:12)
    in App
    in AppContainer (at src/index.js:21)
    at throwException (http://localhost:3000/main.js:86205:17)
    at handleError (http://localhost:3000/main.js:87317:11)
    at performSyncWorkOnRoot (http://localhost:3000/main.js:87037:15)
    at scheduleUpdateOnFiber (http://localhost:3000/main.js:86461:11)
    at updateContainer (http://localhost:3000/main.js:89880:7)
    at http://localhost:3000/main.js:90305:11
    at unbatchedUpdates (http://localhost:3000/main.js:87199:16)
    at legacyRenderSubtreeIntoContainer (http://localhost:3000/main.js:90304:9)
    at render (http://localhost:3000/main.js:90384:14)
    at render (http://localhost:3000/main.js:1769:5)

Environment

Run and copy the result of:

npx envinfo --system --npmPackages react* --binaries --npmGlobalPackages react* --browsers

here:

$ npx envinfo --system --npmPackages react* --binaries --npmGlobalPackages react* --browsers
npx: installed 1 in 1.621s

  System:
    OS: Windows 10 10.0.18362
    CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
    Memory: 3.54 GB / 15.90 GB
  Binaries:
    Node: 10.16.3 - C:\Program Files\nodejs\node.EXE
    npm: 6.9.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: 44.18362.449.0
    Internet Explorer: 11.0.18362.1

Steps to Reproduce the problem

Base your steps off of any freshly installed react-static template!

  1. Create a new react-static site.
  2. Remove the <Suspense /> component.
  3. Run the site.

Expected Behavior

The site should work without a <Suspense /> component per the documentation, or have a flag in <Root /> to turn it off.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:11 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
SleeplessBytecommented, Jan 8, 2020

The docs say:

Note: Make sure to wrap components using useSiteData() with React’s <Suspense fallback="..."></Suspense>. More information on the subject is available here.

What exactly is the bug?

Do you mean that in the docs it only shows <Root><Routes>...</Routes></Root>?

1reaction
OfficerHalfcommented, Jul 17, 2020

Adding <Suspense/> fixes the dev server, but then I get this error on build: https://reactjs.org/docs/error-decoder.html/?invariant=294

ReactDOMServer does not yet support Suspense.

Not sure where to go from here.

EDIT: Actually, the error is there regardless, will open another issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

A React component suspended while rendering, but no ...
Without Using suspense, you can configure that i18n.js like this: i18n .use(XHR) .use(LanguageDetector) .init({ react: { useSuspense: false ...
Read more >
Suspense for Data Fetching (Experimental) - React
We call this approach “fetch-on-render” because it doesn't start fetching until after the component has rendered on the screen. This leads to a...
Read more >
All You Need To Know About React Suspense - CopyCat Blog
The suspense component handles the loading state of the App or any component and will render the fallback UI while loading is true....
Read more >
react-hydration-error - Next.js
When css-in-js libraries are not set up for pre-rendering (SSR/SSG) it will often lead to a hydration mismatch. In general this means the...
Read more >
Introduction to React v18 Suspense and Render-as-You-Fetch ...
The problem arises when you have multiple API calls to fetch data and you need to… ... we have a more capable Suspense...
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