I can't figure out how to pass props to the component. This is important as I don't want to fetch data in the componentDidMount method as it will then be invisible to search engines.
My code looks like this
const router =
<Route path="/" component={App}>
<IndexRoute onEnter={redirectToLogin} component={LandingPage} />
<Route path="panel" component={ ControlPanel }>
...
</Route>
<Route
path="/:handle"
onEnter={maybeRedirectToHome}
getComponent={(location, callback)=> {
getSiteHandleByName(location.pathname.slice(1))
.then(function(handle){
if (handle){
callback(null, Portfolio)
} else {
callback(null, NotFound)
}
})
.catch(callback)
}}
getChildRoutes={(location, callback)=> {
callback(null, portfolioRoutes)
}}
/>
</Route>
I'm trying to serve up a portfolio React App when the user visits a valid url like mysite.com/thishandleisvalid
but I'll need to also fetch all the content for that app at the getComponent
point and pass it in as a property. E.g. you might normally do something like this <Portfolio contentItems={fetchedItems} />
.
Is doing this possible?