Passing custom data (e.g. token) to props during server-side render

#136 · closed · 1 comments

View on GitHub ↗

kulikalov

Client's requests contain user's token if user is authenticated. During server-side render i'm extracting token within ``` ReactRouter.match({routes, location}, (error, redirectLocation, renderProps) => ``` ... and passing it to props. I was implementing it two different ways, but both feels hacky: 1. Create new class from `ReactRouter.RouterContext` and pass props in there along with the others, as RootComponent to transmit. 2. Modify `renderProps` before ``` Transmit.renderToString(ReactRouter.RouterContext, props).then(({reactString, reactData}) => ``` ... as console wasn't complaining about it, i was just putting token along with `renderProps.params`. @RickWong could you share your way of doing that?

Comments

RickWong

This problem is too specific to your project. I can't give you proper advice without seeing more code.