Book Image

React Components

By : Christopher Pitt
Book Image

React Components

By: Christopher Pitt

Overview of this book

The reader will learn how to use React and its component-based architecture in order to develop modern user interfaces. A new holistic way of thinking about UI development will establish throughout this book and the reader will discover the power of React components with many examples. After reading the book and following the example application, the reader has built a small to a mid-size application with React using a component based UI architecture. The book will take the reader through a journey to discover the benefits of component-based user interfaces over the classical MVC architecture. Throughout the book, the reader will develop a wide range of components and then bring them together to build a component-based UI. By the end of this book, readers would have learned several techniques to build powerful components and how the component-based development is beneficial over regular web development.
Table of Contents (17 chapters)
React Components
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Rendering components to strings


One of the beautiful things about React is that it works in many places. It is aimed at rendering interfaces efficiently, but those interfaces can extend outside of the DOM and the browser.

You can use React to render native mobile interfaces (https://facebook.github.io/react-native), or even plain HTML strings. This becomes useful when we want to reuse the component code in different places.

We can, for instance, build an intricate data table component for our CMS. We can ship that component to an iPad application or even render it from the web server as a way of minimizing page load time.

It's the latter example that we will try in this chapter. To begin, we need to install the source versions of React and React DOM libraries:

$ npm install --save babel-cli babel-preset-react babel-preset-es2015 react react-dom

We've already seen examples of the React libraries, but these new ones (from BabelJS) will give us a way of using ES6 and JSX on the server. They even...