.Render React on the Server with renderToString

.Render React on the Server with renderToString
0

#1

Tell us what’s happening:

Hi everybody,How are you?I am good.Can you tell me what is wrong with with this exercise and why is
wrong that code that i write?I am trying to find the wrong but I can’t.

Your code so far


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

// change code below this line
ReactDOMServer.renderToString('App');

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.92 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/front-end-libraries/react/render-react-on-the-server-with-rendertostring


#2

When you are rendering a component. You need to have html like syntax like this.

<nameOfYourComponent />


#3

The instructions do not tell you the exact syntax, but it is similar to ReactDOM.render syntax:

ReactDOMServer.renderToString(element)

How do you refer to an element with ReactDOM.render? It will be the same format.

Hint: It is not a string like you are trying to do.


#4

Ohhh I can’t find i try some codes but again is wrong.What can I do else to find it or can you tell me some more easy explain :slightly_smiling_face:


#5

What have you tried that is different than your first attempt?

I assume you already made it through the first 1-3 challenges in the React section. Go back and review how to render a component to the DOM. Then look at the hints you have been given and you should be able to figure out your mistake.


#6

OK so I will try to find my wrong and I tell you.


#7

class App extends React.Component {
constructor(props) {
super(props);
}
render() {
return


}
};

// change code below this line
ReactDOMServer.renderToString();

This is my new code and is right thank you for helping.


#8

You did not call the renderToString method with the App component. Like I said before, you should review previous
React challenges which you should have already passed to to see how a component is rendered with ReactDOM.render method.
https://learn.freecodecamp.org/front-end-libraries/react/render-a-class-component-to-the-dom


#9

Thanks!, you’re right, the argument is not a string, and we have done similar challenge. so this like a reminder