<commit_before>import React, { Component, PropTypes } from 'react'
import Toast from './Toast'

const messageType = PropTypes.shape({
  text: PropTypes.oneOfType([PropTypes.string, PropTypes.node]).isRequired,
  styles: PropTypes.object,
  duration: PropTypes.number,
  height: PropTypes.number
})

const noop = () => 0

// Inspired by https://github.com/dabit3/react-native-toasts
class Toaster extends Component {
  static propTypes = {
    message: PropTypes.oneOfType([messageType, PropTypes.arrayOf(messageType)]),
    onShow: PropTypes.func,
    onHide: PropTypes.func
  }

  static defaultProps = {
    onShow: noop,
    onHide: noop
  }

  constructor (props) {
    super(props)

    let messages = []

    if (props.message) {
      messages = this.cloneWithId(props.message)
    }

    this.state = { messages }
  }

  cloneWithId (obj) {
    if (Array.isArray(obj)) {
      return obj.map(this.cloneWithId)
    }

    return Object.assign({ id: Math.random().toString(36) }, obj)
  }

  componentWillReceiveProps (nextProps) {
    if (!nextProps.message) return null
    const message = this.cloneWithId(nextProps.message)
    this.setState({ messages: this.state.messages.concat(message) })
  }

  onShow = () => {
    const message = this.state.messages[0]
<commit_msg>Fix extract messages from props in constructor<commit_after>import React, { Component, PropTypes } from 'react'
import Toast from './Toast'

const messageType = PropTypes.shape({
  text: PropTypes.oneOfType([PropTypes.string, PropTypes.node]).isRequired,
  styles: PropTypes.object,
  duration: PropTypes.number,
  height: PropTypes.number
})

const noop = () => 0

// Inspired by https://github.com/dabit3/react-native-toasts
class Toaster extends Component {
  static propTypes = {
    message: PropTypes.oneOfType([messageType, PropTypes.arrayOf(messageType)]),
    onShow: PropTypes.func,
    onHide: PropTypes.func
  }

  static defaultProps = {
    onShow: noop,
    onHide: noop
  }

  constructor (props) {
    super(props)

    let messages = []

    if (props.message) {
      messages = this.cloneWithId(props.message)
      messages = Array.isArray(messages) ? messages : [messages]
    }

    this.state = { messages }
  }

  cloneWithId (obj) {
    if (Array.isArray(obj)) {
      return obj.map(this.cloneWithId)
    }

    return Object.assign({ id: Math.random().toString(36) }, obj)
  }

  componentWillReceiveProps (nextProps) {
    if (!nextProps.message) return
    const message = this.cloneWithId(nextProps.message)
    this.setState({ messages: this.state.messages.concat(message) })
  }

  onShow = () => {
    const message = this.state.messages[0]

{'fraction_non_alphanumeric': 0.1272111403838916, 'fraction_numerical': 0.003763643206624012, 'mean_word_length': 3.459731543624161, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 2, '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': '7436522', 'n_tokens_mistral': 840, 'n_tokens_neox': 838, 'n_words': 179}