No access to original route object data
gucki opened this issue · 3 comments
In a normal react component I can access this.props.route
and get access to the original route definition. With react-router-relay this.props.relay.route
(or when using context this.context.route
) does not contain any original data. It returns an object with the keys name, params, queries. And for example name does not contain the original route name but some autogenerated name like "_aggregated__form__default_root__form__default_offer__inquiries__default_root__inquiries__default_offer".
If this is not a bug but a feature - how to access the current orignal route definition object, just what a normal react component returns with @props.route
? How to access the other router variables like @props.routes
, etc.?
It's just this.props.route
in the route component.
@taion Would be great, but it's not 👎
Here's my component and relay container (coffeescript):
React = require("react")
Relay = require("react-relay")
{withRouter} = require("react-router")
Component = React.createClass
contextTypes:
router: React.PropTypes.object
route: React.PropTypes.object
render: ->
console.log @props.relay.route.name
console.log @props
console.log @context
console.log @props.route
console.log @context.route
div null,
"bla"
Container = Relay.createContainer Component,
fragments:
offer: -> Relay.QL`
...
`
module.exports = withRouter(Container)
The output in the console is:
_aggregated__form__default_root__form__default_offer__inquiries__default_root__inquiries__default_offer
Object {root: Object, offer: Object, children: Object, router: Object, relay: Object}
Object {router: Object, route: Object}
undefined
Object {name: "_aggregated__form__default_root__form__default_off… inquiries__default_root__inquiries__default_offer", queries: Object, params: Object}
As you can see @props.route
is undfined
and @context.route
contains not the original data.
My router config for this config looks like this (this fragment being a child route..):
{
name: "inquiries"
tab: "haha"
path: "inquiries"
component: require("app/pages/offers/edit/inquiries")
queries: Queries("root", "offer")
}
When removing the relay container and passing the react component directly to the router it works as expected.
~# npm list | grep route
├── isomorphic-relay-router@0.8.3 extraneous
├─┬ react-router@2.8.1
├─┬ react-router-relay@0.13.5