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:
import React, { Component } from ‘react’; import Header from ‘./Header’; import Button from ‘./Button’; import CollectionRenameForm from ‘./CollectionRenameForm’; import CollectionExportForm from ‘./CollectionExportForm’; import CollectionActionCreators from ‘../actions/CollectionActionCreators’; import CollectionStore from ‘../stores/CollectionStore’; class CollectionControls extends Component { state = { isEditingName: false } getHeaderText = () => { const { numberOfTweetsInCollection } = this.props; let text = numberOfTweetsInCollection; const name = CollectionStore.getCollectionName(); if (numberOfTweetsInCollection === 1) { text = `${text...