display | more...

ReactJS is an open source view framework for web applications, developed primarily by Facebook. It allows developers to structure the views of their applications using reusable components with clearly defined boundaries, much as they might structure internal controller or model code.

In contrast to other web frameworks, ReactJS' design strives for simplicity and isolation. Developers of React-based views need to think about only three things: components, props, and state.

  • Components are the bread and butter of ReactJS. Everything is a component, which is a self-contained portion of a view. Components never need to know anything about other parts of the application: not what's above them, not what's next to them, not what's happening in the backend—none of that. Components need only care about themselves and any child components they might use.
  • Props are immutable characteristics of Components. When a component is created, we might need to tell it some things, like what color to be or whether to draw in portrait or landscape, or what its content is. These things never change during the lifetime of the component.
  • State contains all of the things in a component that might change during its lifetime: the messages in a chatroom, whether an icon is alerting, etc. Whenever State is changed, ReactJS regenerates the component automagically for you.

That's all there is to React, and it makes for a clean, understandable logic in the creation of views. The biggest decision the developer needs to make in React is whether a particular piece of data belongs in props or state, which is a distinction that has to be thought about anyway, whether or not the framework makes this explicit.

Because React sticks to just the view layer, and does it well, the developer is free to build out the application's backend using any other library. For a more integrated solution, developers can explore Flux, a full application framework also developed by Facebook, which uses React as its view layer.