Want to render asynchronously initialized components on the server. I believe the most practical way to do this is to make an optional prop for the preloaded data, like so:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | getInitialState: function() { if (this.props.initialLastGist) { var lastGist = this.props.initialLastGist; return { username: lastGist.user.login, lastGistUrl: lastGist.html_url }; } else { return {}; } }, componentDidMount: function() { if (!this.props.initialLastGist) { $.get(this.props.source, function(result) { var lastGist = result[0]; this.setState({ username: lastGist.user.login, lastGistUrl: lastGist.html_url }); }.bind(this)); } }, |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.