##Exercise 5: Handle Toggle clicks
- Add a method to
Togglefor handling clicks and logging the event in the console.
// app/components/Toggle.js
_handleClick(event) {
console.debug('Toggle clicked!', event)
}- Add the event handler to the rendered
Toggle.
// app/components/Toggle.js
render() {
return (
<div onClick={this._handleClick}>
{this.props.enabled ? this.props.enabledText : this.props.disabledText}:
{this.props.children}
</div>
)
}- Open the web inspector console, and click the
Toggleto print the log message.
> Toggle clicked! SyntheticMouseEvent {dispatchConfig: Object, ...}
###[Next Step: Hold `Toggle` state in the component →](./exercise-6.md)