About React.js

How to describe React.js…

A javascript library.

Developed by Facebook.

Virtual DOM

Renders user interfaces.

It’s fast.

COMPONENTS.

Everything in React is based on reusable components. These components or views can be describe as code snippets that produce HTML. A component is simply plain, vanilla javascript. Each component returns one DOM (parent) element. In React, the user can define small components and put them together to form bigger components.

There are two main ways data gets handle in React: state and props.

State can be seen as how a component’s data looks at a given point in time. State is a javascript object used to record and react to user events. State is defined in class based components and used for some type of internal record keeping. When state changes on a component, the component will automatically re-render with changes (manages virtual DOM) and update only affected nodes.

Props or properties are used to pass values or data from a parent component to its children. Like HTML properties, we can inject props to give values dynamically. A props value should not be change during its component’s lifecycle.

Lifecycle

  • Initial — when component is created
  • getDefaultProps and getInitialState — methods are only called once when initially rendering component. The initial state value is set and props are defined.
  • componentWillMount — happens before render.
  • render — returns component markup
  • componentDidMount — DOM can be accessed in this method

React is a good framework for single page applications because it is fast. By using a virtual DOM, it can handle updates and render different views efficiently. React’s modularity can also help organize the complexities and views in a SPA.

A single golf clap? Or a long standing ovation?

By clapping more or less, you can signal to us which stories really stand out.