Reactjs React router transition to.。子字符串不是函数
我有一些简单的组件,我想使用router.transitiono函数。我在这里做错了什么:Reactjs React router transition to.。子字符串不是函数,reactjs,react-router,Reactjs,React Router,我有一些简单的组件,我想使用router.transitiono函数。我在这里做错了什么: const { Router, Route, IndexRoute, Redirect, Link, IndexLink } = ReactRouter const Person = React.createClass({ render() { return ( <div>
const { Router,
Route,
IndexRoute,
Redirect,
Link,
IndexLink
} = ReactRouter
const Person = React.createClass({
render() {
return (
<div>
hihihi
</div>
)
}
})
const App = React.createClass({
clickHandler() {
this.context.router.transitionTo('/person/23')
},
render() {
return (
<div>
<h1 onClick={this.clickHandler}>React Router Playground</h1>
{this.props.children}
</div>
)
}
})
App.contextTypes = {
router: React.PropTypes.object.isRequired,
}
React.render((
<Router>
<Route path="/" component={App}/>
<Route path="/person/:id" component={Person}/>
</Router>
), document.getElementById('app'))
const{Router,
路线,,
IndexRoute,
重新使用
链接
索引链接
}=反应路由器
const Person=React.createClass({
render(){
返回(
嗨嗨
)
}
})
const App=React.createClass({
clickHandler(){
this.context.router.transitiono(“/person/23”)
},
render(){
返回(
反应路由器操场
{this.props.children}
)
}
})
App.contextTypes={
路由器:React.PropTypes.object.isRequired,
}
反应((
),document.getElementById('app'))
您拥有的应用程序内组件方法:
clickHandler() {
this.context.router.transitionTo('/person/23')
},
请将其更改为:
clickHandler() {
this.context.router.push('/person/23')
},
工作代码笔:
这是因为react路由器的实际版本使用
路由器。按
更改路由如果您投票关闭,请解释原因。我只是想找到我的答案,因为我在别的地方找不到。