Creating the CollectionControls component
Now, since you understand what the Collection
component renders, let's discuss its child components. We'll start with CollectionControls
. Create the following ~/snapterest/source/components/CollectionControls.js
file:
import React, { Component } from 'react'; import Header from './Header'; import Button from './Button'; import CollectionRenameForm from './CollectionRenameForm'; import CollectionExportForm from './CollectionExportForm'; class CollectionControls extends Component { state = { name: 'new', isEditingName: false }; getHeaderText = () => { const { name } = this.state; const { numberOfTweetsInCollection } = this.props; let text = numberOfTweetsInCollection; if (numberOfTweetsInCollection === 1) { text = `${text} tweet in your`; } else { text = `${text} tweets in your`; } return ( <span> {text} <strong>{name}</strong> collection </span>...