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.

how to use this feature with React Suspense on the server side?

See original GitHub issue
const App = () => {
return (
   <RelayEnvironmentProvider environment={environment} >
          <Suspense fallback={<PageLoding/>}>
            <Layout>
              <Component {...pageProps} />
            </Layout>
          </Suspense>
        </RelayEnvironmentProvider>
);
}


 try {
             const element = <App />

                await ssrPrepass(element);
                return render(renderElementToString, element);
 }
catch (err) {
}

I did something as the abive, still get the two errors

rror: ReactDOMServer does not yet support Suspense.
    at ReactDOMServerRenderer.render (/Users/vidy/www/acme-admin-ui1/node_modules/react-dom/cjs/react-dom-server.node.development.js:3735:25)
    at ReactDOMServerRenderer.read (/Users/vidy/www/acme-admin-ui1/node_modules/react-dom/cjs/react-dom-server.node.development.js:3536:29)
    at renderToString (/Users/vidy/www/acme-admin-ui1/node_modules/react-dom/cjs/react-dom-server.node.development.js:4245:27)
    at render (/Users/vidy/www/acme-admin-ui1/node_modules/next/dist/next-server/server/render.js:81:16)
    at Object.renderPage (/Users/vidy/www/acme-admin-ui1/node_modules/next/dist/next-server/server/render.js:300:24)
[ event ] client pings, but there's no entry for page: /_error
Warning: Relay: Tried reading fragment `BasicLayoutQuery` declared in `useLazyLoadQuery()`, but it has missing data and its parent query `BasicLayoutQuery` is not being fetched.
This might be fixed by by re-running the Relay Compiler.  Otherwise, make sure of the following:
* You are correctly fetching `BasicLayoutQuery` if you are using a "store-only" `fetchPolicy`.
* Other queries aren't accidentally fetching and overwriting the data for this fragment.
* Any related mutations or subscriptions are fetching all of the data for this fragment.
* Any related store updaters aren't accidentally deleting data for this fragment.
Warning: Relay: Expected to have been able to read non-null data for fragment `BasicLayoutQuery` declared in `useLazyLoadQuery()`, since fragment reference was non-null. Make sure that that `useLazyLoadQuery()`'s parent isn't holding on to and/or passing a fragment reference for data that has been deleted.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
kittencommented, Apr 14, 2020

@zenflow This should (or rather used to?) actually work since React introduced an exception to their SSR mismatch checks that accepted an added Suspense boundary on the client-side. I’m not sure whether that was possibly rolled back: https://github.com/facebook/react/pull/16943

Edit: I can’t really find the affected code in the React codebase anymore. So this behaviour may have changed in a minor release. I’m wondering whether this change has moved over to the new createRoot APIs and this is a non-issue there.

Further, I don’t think we can reopen this since it’s not actionable. There’s nothing we can do about this warning if React decided to re-add it unfortunately.

0reactions
zenflowcommented, Aug 3, 2021

@jesster2k10 My workaround in the end was to ignore the warnings. I don’t believe they are actually valid, because of the reasoning above: “The html tree is the exact same on server & browser; only the React element tree is different.” If the html tree actually differed from server to browser (as the warning implies) then we would have a problem, but I don’t see the problem with the React element tree differing.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using React Suspense for Better Server-Side Rendering
React Suspense is a React component that pauses (suspends) an element's rendering unless all the data it requires is available. It assures that...
Read more >
Suspense on the Server in React 18
The <Suspense> component in React can be used to delay component rendering until the data for that component is ready. While waiting, you...
Read more >
Suspense for Data Fetching (Experimental) - React
Suspense for Data Fetching is a new feature that lets you also use <Suspense> to declaratively “wait” for anything else, including data.
Read more >
Deep dive into the new Suspense Server-side Rendering ...
In SSR, data is fetched, and the HTML is generated from the React components on the server. The HTML is then sent out...
Read more >
Suspense in React 18: How it works, and how you can use it
Suspense is the first feature released by the Facebook React team that takes advantage of the new concurrent rendering engine built into ...
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