Hook Tutorial

WARNING! v0.13 was just released, and the tutorial is currently undergoing final testing. It's recommended that you DO NOT follow along until this message is removed (please check back tomorrow).

A tutorial for learning to create your own hooks

Step 6: Integrate Hook

In this step we're going to integrate the hook into our application.

You can view the finished code for this step by checking out the step-6 branch.

Invoke the Hook

With our hook finished, we can now use it in our application. To do that, open up the Feed component and add acomponentDidMount method that invokes the hook like this:

componentDidMount() {
  const { tweets } = this.props;

That's it! This method will now get invoked when the Feed component mounts, and will refetch the list of tweets every 2 seconds.

Check In

With our hook now integrated, open up two browser tabs so we can see this the hook in action. As you create and edit tweets, you'll notice the data syncs across the browsers as they update their stores with the data from the server.

Next Steps

In the next step we're going to talk about publishing your hook.