Uncaught TypeError: Cannot convert undefined or null to object
`import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { connect } from 'react-redux'; import { loginUser } from '../../actions/authentication'; import Form from 'react-validation/build/form'; import Input from 'react-validation/build/input'; import Button from 'react-validation/build/button'; import {required, email, password} from '../../validations/common.js'; import { Redirect } from 'react-router';
class Login extends Component {
constructor() { super(); this.state = { email: '', password: '', errors: {} } this.handleInputChange = this.handleInputChange.bind(this); this.handleSubmit = this.handleSubmit.bind(this); }
handleInputChange(e){ this.setState({ [e.target.name]: e.target.value }) }
handleSubmit(e) { e.preventDefault() const user = { email: this.state.email, password: this.state.password } this.props.loginUser(user) }
componentWillReceiveProps(nextProps) { if(nextProps.auth.isAuthenticated) { this.props.history.push('/') } if(nextProps.errors) { this.setState({ errors: nextProps.errors }); } } componentDidMount() { if(this.props.auth.isAuthenticated) { this.props.history.push('/'); } } render() { return ( <div className='container login-container'> <div className='row'> <div className='col-md-3'> <div className='col-md-6 login-form-1'>
LOGIN
{this.state.errors.message && (<div className='text-center error-message'>{this.state.errors.message})} <Form ref={c => { this.form = c }} onSubmit={ this.handleSubmit }> <div className='form-group'> <Input type='text' name='email' className='form-control' placeholder='Your Email *' onChange={ this.handleInputChange } value={ this.state.email } ref={c => { this.userInput = c }} validations={[required, email]} /> <div className='form-group'> <Input type='password' name='password' className='form-control' placeholder='Your Password *' onChange={ this.handleInputChange } value={ this.state.password } validations={[required, password]} maxLength='12' minLength='7' /> <div className='form-group'> <Button className='btnSubmit'>Login</Button> <div className='form-group'> <a className='btnForgetPwd'>Forget Password? </Form> <div className='col-md-3'> ); } }Login.propTypes = { auth: PropTypes.object.isRequired, errors: PropTypes.object.isRequired }
const mapStateToProps = (state) => ({ auth: state.auth, errors: state.errors })
export default connect(mapStateToProps, { loginUser }) (Login)`
Upon leaving the component with the Form/Inputs
form.js:67 Uncaught TypeError: Cannot convert undefined or null to object
at Function.from (