<commit_before>import React, { Component } from 'react';
import QuotesComponent from '../components/Quote';
import { prefetchRandomQuote, getRandomPrefetchedQuote } from '../api';
import { getRandomLocalQuote } from '../quotes.local';
import Settings from '../settings';

let quoteObject;

// if allowed to fetch from server
// begin with assuming we have a
// prefetched quote from the api
if (Settings.fetchFromServer) {
    quoteObject = getRandomPrefetchedQuote();
}

// fallback to the locally stored quote
quoteObject = quoteObject || getRandomLocalQuote();

class Quotes extends Component {
    componentDidMount() {
        Settings.fetchFromServer && prefetchRandomQuote();
    }

    render() {
        const author  = quoteObject.quoteAuthor || 'Anonymous';
        const text = quoteObject.quoteText;
        const props = { author, text };

        return (
            Settings.showQuotes && <QuotesComponent { ...props } />
        );
    }
}

export default Quotes;<commit_msg>:art: Fix Quotes container to use state<commit_after>import React, { Component } from 'react';
import QuotesComponent from '../components/Quote';
import { prefetchRandomQuote, getRandomPrefetchedQuote } from '../api';
import { getRandomLocalQuote } from '../quotes.local';
import Settings from '../settings';

let quoteObject;

// if allowed to fetch from server
// begin with assuming we have a
// prefetched quote from the api
if (Settings.fetchFromServer) {
    quoteObject = getRandomPrefetchedQuote();
}

// fallback to the locally stored quote
quoteObject = quoteObject || getRandomLocalQuote();

class Quotes extends Component {
    state = {
        fetchFromServer: Settings.fetchFromServer,
        showQuotes: Settings.showQuotes,
        quote: quoteObject,
    };

    componentDidMount() {
        const { fetchFromServer } = this.state;
        fetchFromServer && prefetchRandomQuote();
    }

    render() {
        const { showQuotes, quote = {} } = this.state;

        const author  = quote.quoteAuthor || 'Anonymous';
        const text = quote.quoteText;
        const props = { author, text };

        return (
            showQuotes && <QuotesComponent { ...props } />
        );
    }
}

export default Quotes;
{'fraction_non_alphanumeric': 0.11041292639138241, 'fraction_numerical': 0.0, 'mean_word_length': 3.0675182481751824, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '117687', 'n_tokens_mistral': 606, 'n_tokens_neox': 582, 'n_words': 179}