Questions tagged [react-dom-server]

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

74 questions
0
votes
1 answer

Cannot read properties of undefined (reading '_internalRoot')

I am trying to switch the rendering method according to the env flag. since i am much new for react needs the help to understand the correct way. getting an error as, TypeError: Cannot read properties of undefined (reading '_internalRoot') here…
0
votes
0 answers

How do I change the div id="__next" to own name in Next.js?

I am making a website with Next.js and I needs to change root div id to own name. I heard that next doesn't currently allow to change the name, but it can be done by writing your own content rendering function, which I read in this article. I also…
Tebyy
  • 53
  • 5
0
votes
0 answers

How to convert JSX to a string that represents it's original code, not the rendered output?

I can covert JSX to a rendered output like so: import { renderToString } from 'react-dom/server' renderToString() which yields:
...
In other words, the text is what…
Edy Bourne
  • 5,679
  • 13
  • 53
  • 101
0
votes
1 answer

ReactDOMServer not found, but it is on package.json

I'm getting this result on my npm start log: Can't resolve 'react-dom/server' in 'C:\Users\Alvaro\git\Fancy\lab\src\components\data-visualization\chart' If you're trying to use a package make sure that 'react-dom/server' is installed. If you're…
0
votes
1 answer

Is there a way to accomplish `renderToStaticMarkup` on the client-side in React 18

We are currently using ReactDOM.renderToStaticMarkup to render a tooltip within highcharts. const chartOptions: Options = { chart: { height }, tooltip: { ..., formatter: function () { return…
scott dickerson
  • 908
  • 1
  • 5
  • 13
0
votes
1 answer

I am trying to create a navbar that link to different route with React/typescript but when i create a link i keep getting an error

import React from 'react' import { Link } from 'react-router-dom' export default function NavBar() { return (
Home Login
Nasiru Ismail
  • 37
  • 1
  • 4
0
votes
2 answers

How to server-side render a specific route in ReactJS?

I would like to server-side render only a specific route in React. For example, /home should be client-side rendered, but /post should be server-side rendered. The /post route receives a post ID as a parameter(using react-router) and fetches the…
0
votes
2 answers

Prevent invalid hook call when calling useContext in a functional component that renders another component?

Here is the example code: import React, { useContext } from 'react'; import { Context } from './MainContext'; import ReactDomServer from 'react-dom/server'; //Import SomeOtherComponent import { SomeOtherComponent} from…
Aib Syed
  • 3,118
  • 2
  • 19
  • 30
0
votes
1 answer

I cannot get the About Component to display on React

I am trying to have my React code display. I followed an ecommerce website YouTube tutorial and I have tried everything to get it to display. I have read up on React routers and switches, but I really cant spot my mistake. The Switch and…
0
votes
0 answers

ReactDomServer vs Next.js SSR

ReactDomServer and Next.js both support server side rendering. Besides developer experience, how are they different?
yume
  • 11
  • 2
0
votes
2 answers

header to be show only in "/" and "/checkout" react reuter dom

I want to be visible only during '/checkout' and '/' instead of in the whole path. it is being difficult to do in react reuter dom v6. import React from "react"; import "./App.css"; import Header from "./Header"; import Home from "./Home"; import…
Vishal Mishra
  • 131
  • 4
  • 11
0
votes
3 answers

Looping through route maps in React Main.js

I am using react-router-dom for my blogs. My Main.js looks like const Main = () => { return ( {/* The Switch decides which component to show based on the current URL.*/}
0
votes
0 answers

React Native Hook issue - Error: Invalid hook call. Hooks can only be called inside of the body of a function component

import { useParams } from 'react-router-dom'; import useFetch from './useFetch'; const BlogDetails = () => { const { id } = useParams(); const { data: blog, error, isPending } = useFetch('http://localhost:3001/blogs/' + id); return…
0
votes
0 answers

How to access deployed BrowserRouter used react project after depolying into tomcat server

I would like to use BrowserRouter for creating multi-page react appplication where I can access different modules with different router names. I can switch between Home and About modules with http://localhost:3000/home and…
HimaaS
  • 413
  • 3
  • 6
  • 13
0
votes
0 answers

Is there a difference in a fetch request body when its created from a user typing the url and when its created from a clicked link?

I have a project that uses React but server rendered. When a client requests an initial page of the website by writing the URL in the search field, the server.js uses renderToString() to stringify the react App.js (with some initial data added) and…
kabison33
  • 101
  • 2
  • 10