我试图在操作中添加push
方法从redux-router
。 当我初始化操作时,推送接收有效载荷中的对象,但不改变页面。 enter image description here如何将从REDX路由器的推送方法添加到操作
动作/ index.js
import { push } from 'redux-router';
export const actions = {};
actions.goTo =() => {
return (dispatch) => {
dispatch(push('/staff'));
};
};
但是,如果我的init 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 '遗漏的类型错误:无法读取属性“类型” undefined'的 – mikilka