Don't load children transmit element
royroev opened this issue · 0 comments
royroev commented
Please help me. Sorry for my English
I have Routes -
<Router>
<Route path="/" component={Main}>
<IndexRoute component={HomePage}/>
<Route path="/search" component={MisterSearchD} ></Route>
...
</Route>
</Router>
When Main - transmit container and HomePage - transmit container.
In Main -
render : function() {
var initialData = this.state.initialData;
return (
<div className={page_class} style={style}>
<div className="container">
<div className="row">
<div className="col-12">
<Header
size={this.state.menuSize}
items={initialData.topMenu}
auth={initialData.authorized}
user={initialData.user}/>
</div>
</div>
React.cloneElement(this.props.children, {
query : this.props.location.query,
pathname: this.props.location.pathname
})}
</div>
</div>
)
}
Main don't wait Home Page. I want load HomePage Component before render Main on server! Client work!
Server code -
ReactRouter.match({routes, location : this.path}, function(error, redirectLocation, renderProps) {
if (error || !renderProps) {
callback(error);
}
Transmit.renderToString(ReactRouter.RouterContext, renderProps).then(function(ref) {
var reactString = ref.reactString;
var reactData = ref.reactData;
new Template("../view/index.html").render(
{
meta_title : meta_.title,
meta_description : meta_.description,
meta_keywords : meta_.keywords,
app : reactString,
data: (!!staticData) ? JSON.stringify(staticData) : ''
}, callback);
})
});