reading-notes

React

What is React?

How does React Work?

React JSX

What is JSX?

JSX allows us to write HTML elements in JavaScript and place them in the DOM without any createElement() or appendChild() methods.

JSX converts HTML tags into react elements.

Rendering Elements

React renders HTML to the web page by using a function called ReactDOM.render().

The ReactDOM.render() function takes two arguments, HTML code and an HTML element.

The purpose of the function is to display the specified HTML code inside the specified HTML element.

React Components

All React components must act like pure functions with respect to their props.

Components let you split the UI into independent, reusable pieces, and think about each piece in isolation.

When creating a React component, the component’s name must start with an upper case letter.

Components come in two types, Class components and Function components.

It requires you to extend from React.Component and create a render function which returns a React element.

It is a plain JavaScript function which accepts props as an argument and returns a React element.

React Props

Props are arguments passed into React components.

Props are passed to components via HTML attributes.