我必须使用它来移动到新页面:
this._reactInternalInstance._context.history.push('/page-one');
this.context
是{}
this.props
为{}
任何人都有提示要解决我在这里显然做错了什么? 感谢
package.json
相关部分
"history": "^1.17.0",
"lodash": "^3.10.1",
"react": "^0.14.3",
"react-addons-css-transition-group": "^0.14.3",
"react-datagrid": "^2.0.1",
"react-dom": "^0.14.3",
"react-multi-dropdown": "^1.0.1",
"react-router": "^1.0.3",
"react-select": "^0.9.1",
"reflux": "^0.3.0",
import React from 'react';
import Reflux from 'reflux';
import RouterContext from 'react-router';
import History from 'history';
import Auth from '../stores/auth-store';
module.exports = React.createClass({
mixins: [
Reflux.listenTo(Auth, 'onDataChange'),
History
],
loginClicked(event) {
if (Auth.loggedIn()) {
this._reactInternalInstance._context.history.push('/page-one');
}
},
答案 0 :(得分:0)
您需要指定contextTypes
才能使用this.context
。请参阅https://facebook.github.io/react/docs/context.html。