我正在使用 react-router 和 react-router-relay 来处理我的应用程序上的路由。我在尝试访问在 url 路径中传递的 id 参数时遇到问题。这样做的正确方法是什么?
路由.js
import CreativeQuery from './CreativeQuery';
<Route path='/creative' component={CreativeComponent} queries={ViewerQuery}>
<Route path="/creative/edit/:id" component={CreativeEditComponent} queries={CreativeQuery}/>
创意查询.js
import Relay from 'react-relay';
export default {
creative: (Component) => Relay.QL`
query {
creative(id:$id) { #<--- id from the url param
${Component.getFragment('creative')}
}
}
`
};