我試圖在操作中添加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