Refactoring the TweetList component

The TweetList component renders a list of tweets. Each tweet is a Tweet component that a user can click on to remove it from a collection. Does it sound like it could make use of CollectionActionCreators to you?

That's right, let's add the CollectionActionCreators module to it:

var CollectionActionCreators = require('../actions/CollectionActionCreators');

Then, we create the removeTweetFromCollection() callback function that will be called when a user clicks on a tweet image:

removeTweetFromCollection: function (tweet) {
  CollectionActionCreators.removeTweetFromCollection(tweet.id);
},

As you can see, it creates a new action through the removeTweetFromCollection() function by passing the tweet ID to it as an argument. ...

Get React.js Essentials 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.