You are previewing Getting Started with React.
O'Reilly logo
Getting Started with React

Book Description

A light but powerful way to build dynamic real-time applications using ReactJS

About This Book

  • Learn how to develop powerful JavaScript applications using ReactJS

  • Integrate a React-based app with an external API (Facebook login) while using React components, with the Facebook developer app

  • Implement the Reactive paradigm to build stateless and asynchronous apps with React

  • Who This Book Is For

    This book is for any front-end web or mobile-app developer who wants to learn ReactJS. Knowledge of basic JavaScript will give you a good head start with the book.

    What You Will Learn

  • Understand the ReactJS basics through an overview

  • Install and create your first React component

  • Refactor the ReactJS component using JSX

  • Integrate your React application with the Facebook login and Graph API, then fetch data from your liked pages in Facebook and display them in a browser

  • Handle UI elements events with React, respond to users input, and create stateful components

  • Use some core lifecycle events for integration and find out about ES6 syntaxes in the React world

  • Understand the FLUX architecture and create an application using FLUX with React

  • Make a component more reusable with mixins and validation helpers and structure your components properly

  • Explore techniques to test your ReactJS code

  • Deploy your code using webpack and Gulp

  • In Detail

    ReactJS, popularly known as the V (view) of the MVC architecture, was developed by the Facebook and Instagram developers. It follows a unidirectional data flow, virtual DOM, and DOM difference that are generously leveraged in order to increase the performance of the UI.

    Getting Started with React will help you implement the Reactive paradigm to build stateless and asynchronous apps with React. We will begin with an overview of ReactJS and its evolution over the years, followed by building a simple React component. We will then build the same react component with JSX syntax to demystify its usage. You will see how to configure the Facebook Graph API, get your likes list, and render it using React.

    Following this, we will break the UI into components and you’ll learn how to establish communication between them and respond to users input/events in order to have the UI reflect their state. You’ll also get to grips with the ES6 syntaxes.

    Moving ahead, we will delve into the FLUX and its architecture, which is used to build client-side web applications and complements React’s composable view components by utilizing a unidirectional data flow. Towards the end, you’ll find out how to make your components reusable, and test and deploy them into a production environment. Finally, we’ll briefly touch on other topics such as React on the server side, Redux and some advanced concepts.

    Style and approach

    The book follows a step-by-step, practical, tutorial approach with examples that explain the key concepts of ReactJS. Each topic is sequentially explained and contextually placed to give sufficient details of ReactJS.

    Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at If you purchased this book elsewhere, you can visit and register to have the code file.

    Table of Contents

    1. Getting Started with React
      1. Table of Contents
      2. Getting Started with React
      3. Credits
      4. About the Authors
      5. Acknowledgments
      6. About the Reviewers
        1. eBooks, discount offers, and more
          1. Why subscribe?
      8. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Downloading the example code
          2. Downloading the color images of this book
          3. Errata
          4. Piracy
          5. Questions
      9. 1. Getting Started with ReactJS
        1. Introducing ReactJS
          1. Who uses ReactJS?
        2. Downloading ReactJS
          1. Installing ReactJS with NPM
          2. Installing ReactJS with Bower
        3. Tools
          1. Text editors
          2. Chrome extension
        4. Trying ReactJS
          1. Configuring ReactJS in a web page
          2. Creating your first React component
          3. Configuring JSX
          4. Serving files through the web server
          5. Creating a React component with the JSX syntax
        5. Summary
      10. 2. Exploring JSX and the ReactJS Anatomy
        1. What is JSX?
        2. Why JSX?
          1. Tools for transforming JSX
        3. The ReactJS anatomy
          1. Creating a component
          2. Rendering a component
          3. Maximum number of roots
          4. Children components
          5. Supported attributes
          6. Supported elements
            1. HTML elements
            2. SVG elements
        4. Learning JSX and Gotchas
          1. Expressions
          2. Properties/attributes
            1. Transferring properties
            2. Mutating properties
          4. Component style
            1. Style
            2. CSS classes
        5. Summary
      11. 3. Working with Properties
        1. Component properties
          1. Data flow with properties
        2. Configuring Facebook Open-Graph API
          1. What it is and how to configure it
          2. Creating an app-id on the Facebook developers site
          3. Open-Graph JavaScript SDK
        3. Rendering data in a ReactJS component
        4. Summary
      12. 4. Stateful Components and Events
        1. Properties versus states in ReactJS
        2. Exploring the state property
          1. Initializing a state
          2. Setting a state
          3. Replacing a state
          4. A React state example using an interactive form
        3. Events
          1. Form events
          2. Mouse events
          3. nativeEvent
          4. Event pooling
          5. Supported events
        4. Summary
      13. 5. Component Life cycle and Newer ECMAScript in React
        1. React component lifecycle
          1. Mounting category
          2. Updating category
          3. Unmounting category
        2. Other ES (ECMAScript) versions in React
          1. ES6
          2. ES7
        3. Summary
      14. 6. Reacting with Flux
        1. An overview of Flux
        2. Flux versus the MVC architecture
          1. Flux advantages
          2. Flux components
        3. Actions
        4. Dispatchers
        5. Stores
        6. Controller-Views and Views
        7. Revisiting the code
        8. Summary
      15. 7. Making Your Component Reusable
        1. Understanding Mixins
          1. Exploring Mixins by example
          2. Higher-order components in Mixins
        2. Validations
          1. An example using the isRequired validator
          2. An example using custom validator
        3. The structure of component
        4. Summary
      16. 8. Testing React Components
        1. Testing in JavaScript using Chai and Mocha
        2. Testing using ReactTestUtils
          1. Installing React and JSX
        3. The jestTypical example of a Testsuite with Mocha, expect, ReactTestUtils and Babel
        4. Testing with shallow rendering
        5. Summary
      17. 9. Preparing Your Code for Deployment
        1. An introduction to Webpack
          1. Building a simple React application
          2. Setting up Webpack
        2. Advantages of Webpack
        3. Introduction to Gulp
          1. Installing Gulp and creating Gulp file
        4. Summary
      18. 10. What's Next
        1. AJAX in React
        2. React Router
        3. Server-side rendering
          1. ReactDOMServer
        4. Isomorphic applications
        5. Hot reloading
        6. Redux React
        7. Relay and GraphQL
        8. React Native
        9. References
        10. Summary
      19. Index