<commit_before>import React, { Component } from 'react'
import firebase from 'firebase'
import {HashLink as Link} from 'react-router-hash-link'

import _copyNested from '../_shared/_copyNested'

import Option from './Option'
import './QuizView.css'

class QuizView extends Component {
  constructor (props) {
    super(props)

    this.state = {
      answerData: this.props.answerData,
    }

    this._onInputChange = this._onInputChange.bind(this)
    this._onInputSubmit = this._onInputSubmit.bind(this)
    this._onSelect = this._onSelect.bind(this)
  }

  componentWillReceiveProps (nextProps) {
    this.setState((prevState, props) => {
      return {
        answerData: nextProps.answerData,
      }
    })
  }

  _onInputChange (event) {

    this.setState((prevState, props) => {
      prevState.answerData = event.target.value || ''
      return prevState
    })
  }

  _onInputSubmit (event) {
    firebase.database().ref(`answer/${this.props.answerOwner}/${this.props.quizData.id}`).set(this.state.answerData)
  }

  _onSelect (event) {
    firebase.database().ref(`answer/${this.props.answerOwner}/${this.props.quizData.id}`).set(event.target.getAttribute('data-value'))
  }

  render () {

    const orderData = this.props.orderData || {}

    const quizData = this.props.quizData
    const optionData = quizData.option
    const routeData = quizData.route

    const answerData = this.state.answerData

    let answerDataJSX
<commit_msg>fix homepage<commit_after>import React, { Component } from 'react'
import firebase from 'firebase'
import {HashLink as Link} from 'react-router-hash-link'

import _copyNested from '../_shared/_copyNested'

import Option from './Option'
import './QuizView.css'

class QuizView extends Component {
  constructor (props) {
    super(props)

    this.state = {
      answerData: this.props.answerData,
    }

    this._onInputChange = this._onInputChange.bind(this)
    this._onInputSubmit = this._onInputSubmit.bind(this)
    this._onSelect = this._onSelect.bind(this)
  }

  componentWillReceiveProps (nextProps) {
    this.setState((prevState, props) => {
      return {
        answerData: nextProps.answerData,
      }
    })
  }

  _onInputChange (event) {

    this.setState((prevState, props) => {
      prevState.answerData = event.target.value || ''
      return prevState
    })
  }

  _onInputSubmit (event) {
    firebase.database().ref(`answer/${this.props.answerOwner}/${this.props.quizData.id}`).set(this.state.answerData)
  }

  _onSelect (event) {
    firebase.database().ref(`answer/${this.props.answerOwner}/${this.props.quizData.id}`).set(event.target.getAttribute('data-value'))
  }

  render () {

    const orderData = this.props.orderData || {}

    const quizData = this.props.quizData
    if (!quizData) {
      return null
    }

    const optionData = quizData.option
    const routeData = quizData.route

    const answerData = this.state.answerData

    let answerDataJSX

{'fraction_non_alphanumeric': 0.13105316627158822, 'fraction_numerical': 0.0, 'mean_word_length': 3.3377386196769456, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '312842', 'n_tokens_mistral': 956, 'n_tokens_neox': 935, 'n_words': 165}