Refactoring the CollectionControls component
The CollectionControls
component gets some major improvements as well. Let's take a look at the refactored version first, and then discuss what was updated and why:
var React = require('react'); var Header = require('./Header.react'); var Button = require('./Button.react'); var CollectionRenameForm = require('./CollectionRenameForm.react'); var CollectionExportForm = require('./CollectionExportForm.react'); var CollectionActionCreators = require('../actions/CollectionActionCreators'); var CollectionStore = require('../stores/CollectionStore'); var CollectionControls = React.createClass({ getInitialState: function () { return { isEditingName: false }; }, getHeaderText: function () { var numberOfTweetsInCollection = this.props.numberOfTweetsInCollection; var text = numberOfTweetsInCollection; var name = CollectionStore.getCollectionName(); if (numberOfTweetsInCollection === 1) { text = text + ' tweet...