O'Reilly logo

React.js Essentials by Artemij Fedosejev

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Refactoring the Stream component

Now, with the Flux architecture in place, we will rethink how our React components get the data that they need to render. As you know, there are usually two sources of data for a React component:

  • Calling another library; for example, in our case, calling the jQuery.ajax() method or SnapkiteStreamClient.initializeStream()
  • Receiving data from a parent React component via the props object

We want our React components not to use any external libraries to receive data. Instead, from now on, they will get that same data from stores. Keeping this plan in mind, let's refactor our Stream component.

Here is how it looks now:

var React = require('react'); var SnapkiteStreamClient = require('snapkite-stream-client'); var StreamTweet ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required