I am confused about Render React on the Server with renderToString

Tell us what’s happening:
Describe your issue in detail here.

**Your code so far**

class App extends React.Component {
constructor(props) {
  super(props);
}
render() {
  return <div>
    <h1>test</h1>
  </div>
}
};

var a = ReactDOMServer.renderToString(<App />);
console.log(a);
**Your browser information:**

Basically what I am trying to ask is I tried locally on my machine, and it does not return anything. Can anyone share a minimized git repo to me that can show how it works

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.83 Safari/537.36

Challenge: Render React on the Server with renderToString

Link to the challenge:

I have never used it. It might just be how the challenge is set up that is causing it not to actually return anything.

Do you have a minimized git repo to simulate this behavior?

Why does it need to be a repo? Can’t you just look at the StackBlitz I posted?

Are you trying to use it client-side or server-side? The method works for both.

WOW. Thanks a lot!!!

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.