Passing props to Transmit
joa-queen opened this issue · 4 comments
joa-queen commented
Hi, I want to send props from the server to Transmit (I'm using the react-isomorphic-starterkit).
Si I have this on server:
renderProps.auth = 'authstring'
Transmit.renderToString(ReactRouter.RoutingContext, renderProps).then(({reactString, reactData}) => {
...
});
And then in my component definition, I have the following:
export default Transmit.createContainer(AppWrapper, {
initialVariables: { },
fragments: {
doSomething: () => {
//Want to read my authstring here
}
}
});
carlosvillu commented
Maybe you need do something like this:
const AuthRoutingContext = (props) => {
return (< RoutingContext {...props} variables={{auth: 'authstring'}}) />
}
Transmit.renderToString(AuthRoutingContext, renderProps).then(({reactString, reactData}) => {
...
});
And then
export default Transmit.createContainer(RoutingContext, {
initialVariables: {
auth: ''
},
fragments: {
doSomething: ({auth}) => {
//Want to read my authstring here
}
}
});
joa-queen commented
It doesn't work.
Am I missing something in my routes definitions?
module.exports = (
<Router component={AppWrapper}>
<Route path="/" component={Main} />
</Router>
);
carlosvillu commented
You have to do the same, but in your AppWrapper in the router.
const AppWrapperRouter = (props) => {
return (<AppWrapper {...props} variables={{auth: 'authstring'}}) />)
}
module.exports = (
<Router component={AppWrapperRouter}>
<Route path="/" component={Main} />
</Router>
);
That will work for sure.
joa-queen commented
The thing is that I need 'authstring' to come from the server.