Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

onTick undefined when application runs.

So if anyone has an issue with the componentdidmount () in the stopwatch.js

convert the function into an arrow function invocation so the this context is preserved.

componentDidMount () {
    // this.interval = setInterval(this.onTick) PREVIOUSLY
        this.interval = setInterval(
        () => this.onTick()
        );
};

In addition if the buttons do not work make sure to bind the this context on the JSX side like so..

        <button onClick={this.onStop.bind(this)}>Stop</button>
        :
        <button onClick={this.onStart.bind(this)}>Start</button>
        }
        <button onClick={this.onReset.bind(this)}>Reset</button>

^ --- you can do this here or in the constructor of the class and bind the funciton this context.

Had this bug running this application on my own React boilerplate, thought it would be helpful to some people if they did the same. :)