Skip to content

Latest commit

 

History

History
35 lines (20 loc) · 992 Bytes

1-3-react-jsx-and-rendering-elements.md

File metadata and controls

35 lines (20 loc) · 992 Bytes

Ironhack Logo

React | JSX and elements

The following code takes the tag with the id root and sets its content to <h1>Hello, world!</h1>

ReactDOM.render(
  <h1>Hello, world!</h1>,
  document.getElementById('root')
);

You can see JSX as a new type. Now you can store in a variable a JSX as you would store a number for example.

Be careful in JSX, self closing tag, such as img, must be ended by />.

const element = <img src={user.avatarUrl} />;

The only thing to remember here is that ReactDOM.render() is a function we will use once in the future and that will display our React applciation.