<commit_before>// @flow
import React from 'react'
import uuid from 'uuid'
import equal from 'deep-equal'

import SearchActions from '../actions/SearchActions.js'
import Components from '../constants/QueryComponentConstants.js'

import { connect } from 'react-redux'
import { addQueryComponent, modifyQueryComponent, removeQueryComponent, makeSearchRequest } from '../actions/query'

class base extends React.Component {
  constructor(props) {
    super(props)
    this.state = { uuid: uuid.v4() }
  }

  componentDidMount() {
    const { namespace, componentName, data } = this.props
    const { uuid } = this.state
    SearchActions.update(namespace, uuid, componentName, data)
    this.props.addQueryComponent(uuid, namespace, data, componentName)

    if (this.props.runOnMount) {
      // SearchActions.nsearch(this.props.namespace)
      this.props.makeSearchRequest()
    }

  }

  componentWillReceiveProps(newProps) {
    if (!newProps.runIfSame && equal(newProps, this.props)) {
      return
    }
    const { namespace, componentName, data } = newProps
    const { uuid } = this.state
    SearchActions.update(namespace, uuid, componentName, data)<commit_msg>Don't update Base component if data is the same<commit_after>// @flow
import React from 'react'
import uuid from 'uuid'
import equal from 'deep-equal'

import SearchActions from '../actions/SearchActions.js'
import Components from '../constants/QueryComponentConstants.js'

import { connect } from 'react-redux'
import { addQueryComponent, modifyQueryComponent, removeQueryComponent, makeSearchRequest } from '../actions/query'

class base extends React.Component {
  constructor(props) {
    super(props)
    this.state = { uuid: uuid.v4() }
  }

  componentDidMount() {
    const { namespace, componentName, data } = this.props
    const { uuid } = this.state
    SearchActions.update(namespace, uuid, componentName, data)
    this.props.addQueryComponent(uuid, namespace, data, componentName)

    if (this.props.runOnMount) {
      // SearchActions.nsearch(this.props.namespace)
      this.props.makeSearchRequest()
    }

  }

  componentWillReceiveProps(newProps) {
    if (!newProps.runIfSame && equal(newProps.data, this.props.data)) {
      return
    }
    const { namespace, componentName, data } = newProps
    const { uuid } = this.state
    SearchActions.update(namespace, uuid, componentName, data)
{'fraction_non_alphanumeric': 0.11293031066330815, 'fraction_numerical': 0.0008396305625524769, 'mean_word_length': 3.91340206185567, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '487401', 'n_tokens_mistral': 683, 'n_tokens_neox': 686, 'n_words': 169}