freeCodeCamp Challenge Guide: Render HTML Elements to the DOM

Render HTML Elements to the DOM


Problem Explanation

To render an element to the DOM, we use the following syntax

ReactDOM.render(<item to be rendered>, <where to be rendered>);

Use the Document method getElementById() to target a specfic node in the DOM

document.getElementByID(<target node>)

Use the Document method getElementById() as an argument within the ReactDOM method render() to solve this challenge.


Solutions

Solution 1 (Click to Show/Hide)

Following the syntax, we would add this line of code to render the JSX element to the div with the id of challenge-node.

ReactDOM.render(JSX, document.getElementById("challenge-node"));
40 Likes