Creating a Collection component
You might recall that our topmost hierarchy Application
component has two child components: Stream
and Collection
.
So far, we've discussed and implemented our Stream
component and its child components. Next, we're going to focus on our Collection
component.
Create the ~/snapterest/source/components/Collection.react.js
file:
var React = require('react'); var ReactDOMServer = require('react-dom/server'); var CollectionControls = require('./CollectionControls.react'); var TweetList = require('./TweetList.react'); var Header = require('./Header.react'); var Collection = React.createClass({ createHtmlMarkupStringOfTweetList: function () { var htmlString = ReactDOMServer.renderToStaticMarkup( <TweetList tweets={this.props.tweets} /> ); var htmlMarkup = { html: htmlString }; return JSON.stringify(htmlMarkup); }, getListOfTweetIds: function () { return Object.keys(this.props.tweets); }, getNumberOfTweetsInCollection...