<commit_before>'use strict';

import React from 'react';
import { render } from 'react-dom';

const backgroundColors = [
  '#EF5350',
  '#F06292',
  '#9575CD',
  '#40C4FF',
  '#26A69A',
  '#8BC34A',
  '#26C6DA',
  '#607D8B',
  '#FF5722',
  '#6D4C41'
];

const backgroundColor = backgroundColors[Math.floor(Math.random() * backgroundColors.length)]

class RedditTrivia extends React.Component {
  constructor() {
    let subreddits = ['askscience', 'explainlikeimfive', 'todayilearned'];
    let rand = Math.floor(Math.random() * subreddits.length)
    let subreddit = subreddits[rand];
    super();

    if (localStorage.post) {
      this.state = { post: JSON.parse(localStorage.post) };
      localStorage.post = null;
    } else {
      this.state = {};
    }

    fetch('https://www.reddit.com/r/' + subreddit + '.json')
      .then((response) => response.json())
      .then((json) => {
        let posts = json.data.children;
        let rand = Math.floor(Math.random() * posts.length);
        let post = posts[rand];
        let randNext = Math.floor(Math.random() * posts.length);
        let postNext = posts[rand];
        localStorage.post = JSON.stringify({
          url : postNext.data.url,
          title: postNext.data.title,
          subreddit: postNext.data.subreddit,
          permalink: postNext.data.permalink
        });

        if (!this.state.post) {
          this.setState({ post: post.data });
        }
      });
  }
  render() {
    let post = this.state.post || {};
    let style = { backgroundColor };

    console.log(post.title);
    return (
      <main>
        <header style={style}>
          <h1><a href={post.url} dangerouslySetInnerHTML={ { __html: post.title } }></a></h1>
        </header>
        <footer>
          <h2><a href={'https://www.reddit.com' + post.permalink}>/r/{post.subreddit}</a></h2>
        </footer>
      </main>
    );<commit_msg>Use const<commit_after>'use strict';

import React from 'react';
import { render } from 'react-dom';

const backgroundColors = [
  '#EF5350',
  '#F06292',
  '#9575CD',
  '#40C4FF',
  '#26A69A',
  '#8BC34A',
  '#26C6DA',
  '#607D8B',
  '#FF5722',
  '#6D4C41'
];

const backgroundColor = backgroundColors[Math.floor(Math.random() * backgroundColors.length)]

class RedditTrivia extends React.Component {
  constructor() {
    const subreddits = ['askscience', 'explainlikeimfive', 'todayilearned'];
    const rand = Math.floor(Math.random() * subreddits.length)
    const subreddit = subreddits[rand];
    super();

    if (localStorage.post) {
      this.state = { post: JSON.parse(localStorage.post) };
      localStorage.post = null;
    } else {
      this.state = {};
    }

    fetch('https://www.reddit.com/r/' + subreddit + '.json')
      .then((response) => response.json())
      .then((json) => {
        const posts = json.data.children;
        const rand = Math.floor(Math.random() * posts.length);
        const post = posts[rand];
        const randNext = Math.floor(Math.random() * posts.length);
        const postNext = posts[rand];
        localStorage.post = JSON.stringify({
          url : postNext.data.url,
          title: postNext.data.title,
          subreddit: postNext.data.subreddit,
          permalink: postNext.data.permalink
        });

        if (!this.state.post) {
          this.setState({ post: post.data });
        }
      });
  }
  render() {
    const post = this.state.post || {};
    const style = { backgroundColor };

    console.log(post.title);
    return (
      <main>
        <header style={style}>
          <h1><a href={post.url} dangerouslySetInnerHTML={ { __html: post.title } }></a></h1>
        </header>
        <footer>
          <h2><a href={'https://www.reddit.com' + post.permalink}>/r/{post.subreddit}</a></h2>
        </footer>
      </main>
    );
{'fraction_non_alphanumeric': 0.16937598321971684, 'fraction_numerical': 0.02202412165705296, 'mean_word_length': 2.4935897435897436, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 35, 'https://': 4, 'lorem ipsum': 0, 'www.': 4, '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': '5468221', 'n_tokens_mistral': 1292, 'n_tokens_neox': 1293, 'n_words': 233}