1
반응에 오류가 정의되지 않은 : 나는 "/ 급여"로 이동하려고 할 때 어떤 이유로링크가 나는 다음과 같은 코드로 응용 프로그램을 반응이 라우터
import { Link } from 'react-router';
var Matches = React.createClass({
contextTypes: {
router: React.PropTypes.object
},
...
componentWillMount: function() {
var router = this.context.router;
...
router.push('/pay');
}
});
, 나는 다음과 같은 예외가 :
"Uncaught ReferenceError: Link is not defined"
내 경로는 다음과 같이 정의된다
var auth_and_info_check = function auth_and_info_check(nextState, replace, callback) {
if (!_horizon_connect2.default.hasAuthToken() && !nextState.location.pathname.endsWith("login")) {
replace({ pathname: '/login' });
callback();
} else if (_horizon_connect2.default.hasAuthToken() && nextState.location.pathname.endsWith("/")) {
_horizon_connect2.default.currentUser().fetch().subscribe(function (user) {
if (!(user.hasOwnProperty('data') && user.data.hasOwnProperty('phone'))) {
replace({ pathname: '/user_info' });
callback();
} else {
callback();
}
});
} else {
callback(); //In my case after routing "/pay" I call this callback
}
};
<Router history={hashHistory}>
<Route component={Layout}>
...
<Route path="/pay" component={Pay} onEnter={auth_and_info_check}/>
...
</Router>
</Router>
당신은 내가 잘못하고있는 무슨 생각을 가지고 있습니까? 에서
당신이 제공 할 수있는'Pay' 구성 요소 코드를 작동하는지? – 1ven
Link 자체의 가져 오기가 작동하지 않는 것 같습니다. 코드에서 어디에서나 사용하고 있습니까? – KumarM
예, 빌드 파일을 살펴 봐야 할 것 같습니다. Link가 최종 js 파일에 포함되도록 확신하지 않는 한, 그게 문제라는 것입니다. 질문에 추가 정보로 추가하고 싶을 수도 있습니다. – KumarM