似乎无法在不使用内部反应实例的情况下重定向

时间:2016-01-05 20:43:49

标签: react-router

我必须使用它来移动到新页面: 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');
        }
   },

1 个答案:

答案 0 :(得分:0)

您需要指定contextTypes才能使用this.context。请参阅https://facebook.github.io/react/docs/context.html