<commit_before>// @flow
import React from "react";

const AddButton = ({ add }: { add: () => void }) =>
  <button className="center-block button-primary" onClick={add}>
    Add task
  </button>;

export default AddButton;<commit_msg>Reformatted AddButton to a React Component, because we needed lifecycle methods for hotkeys<commit_after>// @flow
import React, { Component } from "react";
import Mousetrap from "mousetrap";
import hotkeys from "../utils/hotkeys";

type Props = {
  add: () => void
};

class AddButton extends Component {
  props: Props;

  componentDidMount() {
    Mousetrap.bind(hotkeys.pomodoro.add.addButton.callAdd.key, e => {
      e.preventDefault();
      this.props.add();
    });
  }

  componentWillUnmount() {
    Mousetrap.unbind(hotkeys.pomodoro.add.addButton.callAdd.key);
  }

  render() {
    return (
      <button className="center-block button-primary" onClick={this.props.add}>
        Add task
      </button>
    );
  }
}

export default AddButton;
{'fraction_non_alphanumeric': 0.1396761133603239, 'fraction_numerical': 0.0, 'mean_word_length': 3.5159817351598175, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6408417', 'n_tokens_mistral': 318, 'n_tokens_neox': 312, 'n_words': 76}