Src / action / index.js
import axios from 'axios';
const ROOT_URL = "http://localhost:3090";
export function signinUser({ email, password }){
return function(dispatch){
axios.post(`${ROOT_URL}/signin`, { email, password });
console.log("hey");
}
}
Src / components / authentication
import React, { Component } from 'react';
import { reduxForm } from 'redux-form';
import * as actions from '../../actions';
class Signin extends Component {
handleFormSubmit({ email, password }){
this.props.signinUser({ email, password });
}
render() {
// code
console.log(actions)
const { handleSubmit, fields: { email,password } } = this.props;
return (
<form onSubmit={handleSubmit(this.handleFormSubmit.bind(this))}>
<fieldset className="form-group">
<label>Email:</label>
<input {...email} className="form-control" />
</fieldset>
<fieldset className="form-group">
<label>Password:</label>
<input {...password} className="form-control" />
</fieldset>
<button action="submit" className="btn btn-primary">Sign In</button>
</form>
);
}
// methods
}
export default reduxForm({
form: 'signin',
fields: ['email', 'password']
}, null, actions)(Signin);
I am using a Redux form to create an iconic form. This is the error that I get when I click the "Login" button. The signinUser () function may not be properly defined.
bundle.js: 29019 Uncaught TypeError: this.props.signinUser is not a function (...)
source
share