React · Exercise 1 of 5Next
Intermediate
Render a component to HTML
Play the server. Use renderToString from react-dom/server to turn <Card name="Mango" price={60} /> into an HTML string.
Show that string as text inside <pre id="html"> (set its textContent), and put the same HTML into #root with innerHTML, the way a server response would put it in the page.
Don't use createRoot: the page must come from the HTML string, not from client rendering.
What Check tests
#rootcontains the card headingMango- The card shows the price
₹60 #htmlshows the HTML source as text- Uses
renderToStringand notcreateRoot
Stuck? One hint at a time
The solution unlocks after your first Check. Try first: that is where the learning happens.
Runs in your browser. Your code is saved here.
Your page
Press Run to see the page.
Console
Nothing logged yet.