есть компонента:
import React, {Component} from 'react';
import {connect} from 'react-redux';
import {bindActionCreators} from "redux";
import FilterModels from './FilterModels';
import {getTypes} from '../../actions/AjaxDataActions';
class FilterForm extends Component {
constructor(props) {
super(props);
}
async componentWillMount(){
console.log( 1 );
await this.props.getTypes(this.props.params, this.props.api) ;
console.log( 2 );
}
render() {
console.log( 3 )
return (
<div>
<FilterModels/>
</div>
)
}
}
function matchDispatchToProps(dispatch) {
return bindActionCreators({
getTypes: getTypes
}, dispatch);
}
export default connect(
state => ({
api: state.api,
params: state.ajaxData
}), matchDispatchToProps)(FilterForm);
код
action:
export const getTypes = (object, api) => {
return async dispatch => {
await axios.post(api.url + api.transports + '/' + api.type)
.then(response => {
dispatch({
type: UPDATE_AJAX_PARAMS,
payload: response.data
});
});
}
};
по идеи
console.log должен рисовать 1->2->3, а на практике - 1,3,2
Вопрос - что не так с кодом и как исправить?