- Introduction Now that we’ve learned about JSX, let’s move on to Rendering Elements in React. Rendering elements is the process of displaying them on the screen. Geek and Gal are here to guide you through this important concept in a fun and engaging way!
- Rendering Elements
<div id="root"></div>
const element = <h1>Hello, world!</h1>;
const container = document.getElementById('root');
ReactDOM.render(element, container);
- Hilarious Rendering Example
const name = 'Alice';
const message = `Hey ${name}, why don't scientists trust atoms? Because they make up everything!`;
const element = <h1>{message}</h1>;
const container = document.getElementById('root');
ReactDOM.render(element, container);
- Conclusion
Rendering elements in React involves creating a React element with JSX, selecting a DOM container, and then using the
ReactDOM.render()
function to display the element on the screen. Have fun rendering your React elements and creating amazing apps! 😃