class CreateMethod extends Component{
constructor(props) {
super(props);
}
addField(event) {
console.log('checking',event);
}
submit(values){
let owner = {
"id": 1,
"personClass": "EMP",
"identityNumber": "11001"
}
values.owner = owner;
values.linkedPhases =[]
values.whoColumns = {};
if(this.props){
this.props.pMethodCreate(values);
}
}
clear(){
console.log('clearing the fields')
}
render(){
// const {submit} = this.props
console.log('the props are', this.props)
return(
<div className="users">
<SearchSection
options = {searbarInputs}
onSubmit={this.submit}
onClear={this.clear}
/>
<ValueTable
column2 = 'Method Details'
column3 = 'Description'
column1 = 'Seq No'
option = { methodDesList }
label = "Roles"
/>
<SccButton />
</div>
)
}
}
function mapDispatchToProps(dispatch){
return bindActionCreators({ pMethodCreate }, dispatch)
}
function mapStateToProps(state){
return {state}
}
export default connect(mapStateToProps, mapDispatchToProps)(CreateMethod)
and my reducer is :
import { MEATHOD_CREATE } from "../actions/methodAction";
export default function(state=[], action){
switch(action.type){
case MEATHOD_CREATE :
console.log('the result is', action.payload)
return [...state, action.payload]
default:
return state;
}
return state;
and action is
export function pMethodCreate(requestBody){
return (dispatch)=> {
return axios.post(url+'/save', requestBody).then(response => dispatch(methodCreation(response.data)));
}
}
export function methodCreation(data){
return {
type:MEATHOD_CREATE,
payload : data
}
}
what I am doing wrong, I am trying to submitting the redux-form, I am kind of a newbie to this? I tried to do this by using redux docs but did not get good clarity. and if I am trying to dispatch any get request on componentDidMount() then it's working, don't know which piece of code is killing this?