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
Passing data through to loadProps #43
Comments
I believe it's right way |
There's definitely not a "right way" yet. But ... mutating objects is the wrong way. Maybe a route prop? function createRootRoute(token, routes) {
return <Route token={token} routes={routes} component={App}/>
} |
I would have to wrap my routes in a function and pass them the request I do also think mutating an object is a huge hack too... Hmm. I might be
|
Seems fine to me, they're just descriptors of your routes. |
@zackify @ryanflorence I used it to pass store there:
The only thing... There could be naming collisions here... hm... |
I need this on every route I have, it would be a lot nicer if it could be
|
@zackify got it... and then invoke loadProps with this payload
|
Yeah. Or params could just become an object with params as the required
|
@zackify yeah... agree |
@zackify You're taking your app state and ramming it into router state, where it doesn't belong. You need your own abstraction for dealing with app state. Pass props, put the token on context, redux, etc. But to be clear, you're mixing app and router state in the wrong direction. If you want them in the same place, take the router state and put it into your app state. |
I know it is a rare use case. I haven't found a good way to get around the
|
Heh, it's not rare. We've been talking about this since the router first showed up. If we make a few changes to Async Props, you could use the Router's |
Oh okay, that would be cool!
|
If you want to take a stab at it:
Or something like that ... |
Awesome, will try my hand at this tomorrow. |
Note the loadPropsOnServer(renderProps, loadContext, cb)
// and
<AsyncProps {...renderProps} loadContext={loadContext}/>
// and finally
Component.loadProps = ({ params, loadContext }, cb) => {} |
@ryanflorence haha I was just about to make a PR for this, that's exactly how I expected it to work. Thanks a lot |
I have a use case where I need to get the
request
object inside of loadProps if I am on the server. Is there any way to pass down something through the AsyncProps component? How do you propose adding this?I am doing
renderProps.params.token = req.session.token
aboveloadPropsOnServer
for now.The text was updated successfully, but these errors were encountered: