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) ...
Get React 16 Essentials - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.