-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use with react-router #30
Comments
I see two ways you can achieve that: Option 1It really depends whether you have access to I’ve never tried react-router, but from the doc I can’t really see a way to do that. Is there a global object with all the current route params? If you can get that variable, you’d only need to Option 2Send the collection to the model component instead of the (unknown) model: <Route name="contact"
path="/contacts/:userId"
handler={ContactDetail}
collection={contacts} /> Then you subscribe with the var ContactDetail = React.createBackboneClass({
mixins: [
React.BackboneMixin({
modelOrCollection: function(props) {
return props.collection.get(props.params.userId)
}
})
]
}) Does it make sense? I haven’t tested it, but I think it would work. |
Makes sense. I think option 1 is a no go... I'm not seeing a way to pass that userId in. Pity, it's a more elegant solution. I may post something in the react-router repo about it. Option 2 shows some promise, but the mixin ins't firing for me, any ideas why?
As a side note, I'm looking at flux-react and flux-react-router now too. |
I'm trying to find a good way to use this with react-router. It works wonderfully at the collection level, but I'm not sure how I could set the model on the detail routes, short of hacking them in...
Here's some code:
Any ideas?
The text was updated successfully, but these errors were encountered: