<commit_before>import React from 'react';
import './Note.scss';
import noteRepository from '../../data/NoteRepository';

export default class Note extends React.Component {
  remove() {
    noteRepository.remove(this.props, err => {
      // TODO: inform user
      if (err) throw err;
    });
  }

  render() {
    return (
      <div className="note" onClick={this.props.clickHandler}>
        <h1>{this.props.title}</h1>
        <pre>{this.props.content}</pre>
        <button type="button" onClick={() => this.remove()}>
          <i className="fa fa-trash-o" aria-hidden></i>
        </button>
        <button className="edit" type="button">
          <i className="fa fa-pencil" aria-hidden></i>
        </button>
      </div>
    );
  }
}

// TODO: see if stateless functional component can be reimplemented
// export default function Note({ title, content }) {
//   const remove = () => {
//     console.log('hi');
//   }
//
//   return (
//     <div className="note">
//       <h1>{title}</h1>
//       <pre>{content}</pre>
//       <button type="button" onClick={remove()}>
//         <i className="fa fa-trash-o" aria-hidden></i>
//       </button>
//       <button className="edit" type="button">
//         <i className="fa fa-pencil" aria-hidden></i>
//       </button>
//     </div>
//   );
// }
<commit_msg>Prevent click event from triggering parent handler<commit_after>import React from 'react';
import './Note.scss';
import noteRepository from '../../data/NoteRepository';

export default class Note extends React.Component {
  remove(e) {
    e.stopPropagation();
    noteRepository.remove(this.props, err => {
      // TODO: inform user
      if (err) throw err;
    });
  }

  render() {
    return (
      <div className="note" onClick={this.props.clickHandler}>
        <h1>{this.props.title}</h1>
        <pre>{this.props.content}</pre>
        <button type="button" onClick={e => this.remove(e)}>
          <i className="fa fa-trash-o" aria-hidden></i>
        </button>
        <button className="edit" type="button">
          <i className="fa fa-pencil" aria-hidden></i>
        </button>
      </div>
    );
  }
}

// TODO: see if stateless functional component can be reimplemented
// export default function Note({ title, content }) {
//   const remove = () => {
//     console.log('hi');
//   }
//
//   return (
//     <div className="note">
//       <h1>{title}</h1>
//       <pre>{content}</pre>
//       <button type="button" onClick={remove()}>
//         <i className="fa fa-trash-o" aria-hidden></i>
//       </button>
//       <button className="edit" type="button">
//         <i className="fa fa-pencil" aria-hidden></i>
//       </button>
//     </div>
//   );
// }

{'fraction_non_alphanumeric': 0.19416758951642674, 'fraction_numerical': 0.0029531192321889995, 'mean_word_length': 2.2611311672683514, 'pattern_counts': {'":': 0, '<': 59, '<?xml version=': 0, '>': 65, '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': '3077074', 'n_tokens_mistral': 842, 'n_tokens_neox': 842, 'n_words': 189}