Questions tagged [react-dom-server]

The react-dom/server package allows you to render your components on the server.

74 questions
2
votes
0 answers

React-Dom issue after upgrading to next 12

I have upgraded my large project form Next 10 to Next 12, and I am getting this error: app_container | Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got:…
Atonic
  • 509
  • 1
  • 5
  • 14
2
votes
0 answers

warrning: React.jsx: type is invalid -, caught Error: Element type is invalid: expected a string

my code seems fine but nothing come out, my App.js import logo from './logo.svg'; import './App.css'; import React from 'react'; function App() { return (
2
votes
2 answers

Next Build Error - Error occurred prerendering page / TypeError: Cannot read properties of null (reading 'useMemo')

I'm trying to update a 2 year old project, and I've been having so much trouble after updating the dependencies Right now after running 'next build', I keeps seeing: Error occurred prerendering page "/japan-vlogs". Read more:…
2
votes
1 answer

Different static pages under single url, depending on a cookie

I have two pages which are pretty much the same pages, but one has some additional element to show, and another doesn't. Nothing fancy like some private user data or authentication: pages are purely static. So what I want is to show one of those two…
Jerry Green
  • 1,244
  • 1
  • 15
  • 25
2
votes
2 answers

ReactDom.hydrate removes SSR DOM

In the official docs, it says, React will attempt to attach event listeners to the existing markup. So I thought that if I use ReactDOM.hydrate, it'll only add events. // server.js app.get('/', (req, res) => { const html =…
Jeong Ho Nam
  • 803
  • 12
  • 20
2
votes
0 answers

Is there a way to send React components from server side to client side

I'm wondering if this is possible and if anyone did something similar before. I need a way to serialize react component definitions (essentially react classes, or functions...) on the server side and somehow pass them to the client side. The problem…
alexg
  • 902
  • 11
  • 37
2
votes
2 answers

Is there a way to perform server side rendering of SVG graphics using React?

I am using Highcharts and React for a project and need to support server side rendering for the SVG generated. Could someone suggest a way of doing it so that I get a static rendered page with images as png/jpg? The browser to be used for viewing…
2
votes
1 answer

How to load react component dynamically using require with babel-register

I am using babel-register to use ES6 classes in node environment and want to load and render React component dynamically using require(file_path) with ReactDomServer, but its showing me following error: "Invariant Violation: renderToStaticMarkup():…
2
votes
1 answer

React Server side TypeError: Router.use() requires middleware function but got a string

I'm trying to prep my server to intake ajax calls. I am trying to learn more about React and I have been trying to figure out the server-side. Most of the syntax, I took from different tutorials I've watched. The server.js does connect with the…
2
votes
1 answer

Rendering Maquette to HTML

I want to get an HTML string representation of my Maquette view in order to prerender it to a static html file. React has ReactDOMServer.renderToString. Is there a similar method for Maquette VNodes?
Jesse Hattabaugh
  • 7,876
  • 8
  • 34
  • 38
2
votes
0 answers

Server-side rendering with React - confused about whether we still need templates or not

I was looking at this project https://github.com/DavidWells/isomorphic-react-example I opened this issue https://github.com/DavidWells/isomorphic-react-example/issues/25 Do we need to still use HTML template files? ... or can we just use React…
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
1
vote
1 answer

How to fix "Warning: useLayoutEffect does nothing on the server" while using Material UI and reactDOMServer?

I'm having a issue with ReactDOMServer and Material UI Theme Provider.. Everything is working just fine but I keep getting this annoying error on console: Warning: useLayoutEffect does nothing on the server, because its effect cannot be encoded into…
1
vote
0 answers

Sending React Component styled with MUI5 as HTML string from client to server. Emotion cache data gets lost

I'm sending a React Component styled with MUI5 as HTML string to the backend to generate a PDF. We have separate repos for React app and Node server. This official MUI5 Server Rendering documentation is the reference I settled on. Approach: Convert…
1
vote
0 answers

Generate HTML with css from React elements

i'm trying to generate HTML with css from react elements using the following code. const html = ReactDOMServer.renderToString(); I'm using Material UI components in the react elements. Css is not applied in the generated HTML. How…
1
vote
1 answer

Node.js: Cannot find module react-dom/server

I'm learning React server-side rendering. Using Koa to build the server side. Follow the official document, I installed react and react-dom: yarn add react react-dom And next in my server side entry: import Koa from 'koa' import Router from…
Liam_1998
  • 1,157
  • 3
  • 12
  • 27