Skip to content

Instantly share code, notes, and snippets.

@tmbtech
Created July 15, 2015 17:47
Show Gist options
  • Save tmbtech/f66e210181b23983f9f5 to your computer and use it in GitHub Desktop.
Save tmbtech/f66e210181b23983f9f5 to your computer and use it in GitHub Desktop.
Create Element with static methods
<Router routes={routes}
history={new BrowserHistory()}
createElement={(Component, props) => {
if (Component.fetchData) {
dataFetchers[ Component.displayName ] = Component.fetchData.bind(Component, flux, props);
clearTimeout(dataFetcherTimeout);
dataFetcherTimeout = setTimeout(() => {
Object.keys(dataFetchers).forEach(displayName => dataFetchers[ displayName ]());
dataFetchers = {};
}, 10);
}
return <Component flux={flux} {...props}/>;
}}
/>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment