Book Image

Mastering React

By : Adam Horton, Ryan Vice
Book Image

Mastering React

By: Adam Horton, Ryan Vice

Overview of this book

<p>React stands out in the web framework crowd through its approach to composition. This approach yields blazingly fast rendering capabilities. This book will help you understand what makes React special. It starts with the fundamentals and uses a pragmatic approach, focusing on clear development goals. You'll learn how to combine many web technologies surrounding React into a complete set for constructing a modern web application.</p> <p>With this text, you'll blitz the basics then swiftly move on to advanced topics such as form validation and complete application construction. You'll also explore several design activities which will help you develop your web applications with a thoughtful plan. Finally, you'll learn several methods for implementing slick animations using React.</p>
Table of Contents (18 chapters)
Mastering React
Credits
Foreword
About the Authors
About the Reviewer
www.PacktPub.com
Preface
Free Chapter
1
Introduction to React
3
Dynamic Components, Mixins, Forms, and More JSX
Index

User views


Now that the session management and user store plumbing are in place, we turn our attention to user-related views and components.

The log in view

The log in view is our simplest form. Here's what it looks like in action:

The log in view

Here's the source for the log in view:

File: js/views/login.jsx

import React       from 'react';
import { History } from 'react-router';
import BasicInput  from 'appRoot/components/basicInput';
import Actions     from 'appRoot/actions';

export default React.createClass({
  mixins: [ History ],
  getInitialState: function () { return {}; },
  logIn: function (e) {
    var detail = {};

    Array.prototype.forEach.call(
      e.target.querySelectorAll('input'),
      function (v) {
        detail[v.getAttribute('name')] = v.value;
      });
    e.preventDefault(); 
    e.stopPropagation(); 

    Actions.login(detail.username, detail.password)
      .then(function () {
        this.history.pushState('', '/');
      }.bind(this))
      ['catch'](function...