-
-
Save borm/1064bc3e764765fbce0c to your computer and use it in GitHub Desktop.
React Static Component Load Method
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** @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