-
-
Save vanwagonet/d707683604a3e4ad042a to your computer and use it in GitHub Desktop.
... | |
<Route handler={ require('./main-page') } dataStore={ require('./main-page-data-factory') }> | |
... | |
Router.run(routes, function(err, Handler, state) { | |
let sdata = state.dataStore.getServer(); // Hander.dataStore.getServer() | |
sdata.get().then(funciton(data) { | |
React.renderToString(<Handler data={ data }>); | |
}); | |
}); |
I like it.
http://facebook.github.io/react/tips/initial-ajax.html is antagonistic to server rendering (and therefore isomorphism). I would consider it anti-pattern in Flux.
http://facebook.github.io/react/docs/interactivity-and-dynamic-uis.html recommends "Try to keep as many of your components as possible stateless." I would go a step further and say application state goes in data stores, and only UI state (isFocused, isOpen, drag location, etc) goes in components.
react-router is a controller. It's odd that routes are represented as components, especially since they they don't get rendered. @rpflorence, I think that's the crux of our difference in opinion. You want to represent your controllers as components. I think that controllers choosing the view and model are better represented in another way. The components don't know how to get data, just how to render it.
state.matches[0].dataStore
vstate.matches[0].route.handler.dataStore