Skip to content

Instantly share code, notes, and snippets.

@borm
Forked from simenbrekken/react-load.js
Created March 16, 2016 12:56
Show Gist options
  • Save borm/1064bc3e764765fbce0c to your computer and use it in GitHub Desktop.
Save borm/1064bc3e764765fbce0c to your computer and use it in GitHub Desktop.
React Static Component Load Method
/** @jsx React.DOM */
var AsyncComponent = React.createClass({
getInitialState: function() {
return {
}
},
render: function() {
return <div></div>
},
statics: {
load: function(req, callback) {
$.ajax('/api/dashboard/' + req.params.id).done(callback)
}
}
})
var req = {
params: {
id: 1
}
}
AsyncComponent.load(req, function(err, data) {
var markup = React.renderComponentToString(component)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment