<commit_before>/*
*   Required Props:
*   dbReference: string,
*   labelText: String
*/

import React, {Component} from 'react'
import {base} from '../../config/constants'

export default class counterlabel extends Component {
  constructor(props) {
    super(props);
    this.state = {
      count: 0
    }
  }
  componentDidMount() {
    base.bindToState(this.props.dbReference, {
      context: this,
      state: 'count',
      asArray: true
    });
  }
  
  render() {
    var counter = this.state.count;
    if (counter !== undefined) {
      counter = counter.length
    }
    return (
      <div>
        <h3>
          {this.props.labelText}
          <label>{counter}</label>
        </h3>
      </div>
    )
  }
}

<commit_msg>added global state to labelcounter<commit_after>/*
*   Required Props:
*   dbReference: string,
*   labelText: string
*   state: string
*/

import React, {Component} from 'react'
import {base} from '../../config/constants'
import SimpleState from 'react-simple-state'
const simpleState = new SimpleState()


export default class counterlabel extends Component {
  constructor(props) {
    super(props);
    const count = simpleState.getState(this.props.state);

    this.state = {
      count: count
    }
    
  }
  componentDidMount() {
    base.bindToState(this.props.dbReference, {
      context: this,
      state: 'count',
      asArray: true
    });
  }
  
  render() {
    var counter = this.state.count;
    if (counter !== undefined) {
      counter = counter.length
    }
    simpleState.evoke(this.props.state, {
      count: counter
    });
    return (
      <div>
        <h3>
          {this.props.labelText}
          <label>{counter}</label>
        </h3>
      </div>
    )
  }
}


{'fraction_non_alphanumeric': 0.13463751438434982, 'fraction_numerical': 0.0028768699654775605, 'mean_word_length': 2.2383612662942274, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '122921', 'n_tokens_mistral': 552, 'n_tokens_neox': 551, 'n_words': 122}