Я пытаюсь добавить push
метод от redux-router
в действиях. Когда я инициирую действие, нажимаем на прием объекта в полезной нагрузке, но не изменяйте страницу. enter image description hereКак добавить метод push от redux-router к действиям
действия/index.js
import { push } from 'redux-router';
export const actions = {};
actions.goTo =() => {
return (dispatch) => {
dispatch(push('/staff'));
};
};
Но если я инициализировать push
не от действия, но прямо в компоненте он работает правильно.
MyComponent/index.js
import { push } from 'redux-router';
import { connect } from 'react-redux';
@connect((state) => ({}))
export default class MyComponent extends Component {
constructor (props) {
super(props);
this._goTo = ::this._goTo;
}
_goTo (event) {
event.preventDefault();
const { dispatch } = this.props;
dispatch(push('/staff'));
}
render() {
return (
<section>
<button onClick = { this._goTo }>from component</button>
</section>
);
}
}
Я попробовал это, я получил эту ошибку в replaceRoutesMiddleware.js 'Uncaught TypeError: Не удается прочитать«типа»свойства из undefined' – mikilka