Book Image

React.js Essentials

By : Artemij Fedosejev
Book Image

React.js Essentials

By: Artemij Fedosejev

Overview of this book

Table of Contents (18 chapters)
React.js Essentials
Credits
Foreword
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Refactoring the Application component


Where do we start refactoring our React components? Let's start with the uppermost React component in our components hierarchy, Application.

At the moment, our Application component stores and manages the collection of tweets. Let's remove this functionality, as it's now managed by the collection store. Remove the getInitialState(), addTweetToCollection(), removeTweetFromCollection(), and removeAllTweetsFromCollection() methods from the Application component:

var React = require('react');
var Stream = require('./Stream.react');
var Collection = require('./Collection.react');

var Application = React.createClass({
  render: function () {
    return (
      <div className="container-fluid">

        <div className="row">
          <div className="col-md-4 text-center">

            <Stream onAddTweetToCollection={this.addTweetToCollection} />

          </div>
          <div className="col-md-8">

            <Collection...