Conditional Rendering

In React, you can create distinct components that encapsulate behavior you need. Then, you can render only some of them, depending on the state of your application. Conditional rendering in React works the same way conditions work in JavaScript. Use JavaScript operators like if or the conditional operator to create elements representing the current state, and let React update… Continue reading Conditional Rendering

Published
Categorized as React

State and Lifecycle

This page introduces the concept of state and lifecycle in a React component. You can find a detailed component API reference here. Consider the ticking clock example from one of the previous sections. In Rendering Elements, we have only learned one way to update the UI. We call root.render() to change the rendered output: In this section, we will learn… Continue reading State and Lifecycle

Published
Categorized as React

Components and Props

Components let you split the UI into independent, reusable pieces, and think about each piece in isolation. This page provides an introduction to the idea of components. You can find a detailed component API reference here. Conceptually, components are like JavaScript functions. They accept arbitrary inputs (called “props”) and return React elements describing what should appear… Continue reading Components and Props

Published
Categorized as React

Rendering Elements

Elements are the smallest building blocks of React apps. An element describes what you want to see on the screen: Unlike browser DOM elements, React elements are plain objects, and are cheap to create. React DOM takes care of updating the DOM to match the React elements. Rendering an Element into the DOM. Let’s say… Continue reading Rendering Elements

Published
Categorized as React

React JSX

React prefers developing with JSX files that loosely couples HTML and JS in the same file. You can put any valid JavaScript expression inside the curly braces in JSX. For example, 2 + 2, user.firstName, or formatName(user) are all valid JavaScript expressions. You can use JSX inside of if statements and for loops, assign it to variables, accept it as arguments, and return it from… Continue reading React JSX

Published
Categorized as React