<commit_before>import React, { Component } from 'react'
import { connect } from 'react-redux'
import { register, changeRegisterForm } from '../../../actions/authActions'
import RegisterForm from './RegisterForm'

class Register extends Component {
  componentWillReceiveProps = (newProps) => {
    if(newProps.isRegisterSuccessful && !this.props.isRegisterSuccessful) {
      console.log("REGISTER SUCCESS!")
      //TODO: Login
    }
  }

  handleFormSubmit = (event) => {
    event.preventDefault()
    this.props.dispatch(register(this.props.formState))
  }

  handleFormDataChange = (event) => {
    const target = event.target
    const field = target.name
    const value = target.value
    let newState = Object.assign({}, this.props.formState, {[field]: value})

    this.props.dispatch(changeRegisterForm(newState))
  }


  render () {
    const {formState, error} = this.props
    return ( //TODO: handle request loading
      <div>
        <RegisterForm
          user={formState}
          error={error}
          onChange={this.handleFormDataChange}
          onSubmit={this.handleFormSubmit}/>
      </div>
    )
  }
}

const mapStateToProps = (state) => {
  return {
    ...state.registerReducer
  }
}

export default connect(mapStateToProps)(Register)<commit_msg>fixed register stateToProps error<commit_after>import React, { Component } from 'react'
import { connect } from 'react-redux'
import { register, changeRegisterForm } from '../../../actions/authActions'
import RegisterForm from './RegisterForm'

class Register extends Component {
  componentWillReceiveProps = (newProps) => {
    if(newProps.isRegisterSuccessful && !this.props.isRegisterSuccessful) {
      console.log("REGISTER SUCCESS!")
      //TODO: Login
    }
  }

  handleFormSubmit = (event) => {
    event.preventDefault()
    this.props.dispatch(register(this.props.formState))
  }

  handleFormDataChange = (event) => {
    const target = event.target
    const field = target.name
    const value = target.value
    let newState = Object.assign({}, this.props.formState, {[field]: value})

    this.props.dispatch(changeRegisterForm(newState))
  }


  render () {
    const {formState, error} = this.props
    return ( //TODO: handle request loading
      <div>
        <RegisterForm
          user={formState}
          error={error}
          onChange={this.handleFormDataChange}
          onSubmit={this.handleFormSubmit}/>
      </div>
    )
  }
}

const mapStateToProps = (state) => {
  return {
    ...state.authReducer
  }
}

export default connect(mapStateToProps)(Register)
{'fraction_non_alphanumeric': 0.1282051282051282, 'fraction_numerical': 0.0, 'mean_word_length': 3.1266025641025643, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 17, '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': '1881687', 'n_tokens_mistral': 760, 'n_tokens_neox': 750, 'n_words': 156}