I have a pretty simple React.js
component which I need to make an isomorphic
(rendered on the server). The problem is that component rendered with helpful information only after ajax
request completes, like that:
export default React.createClass({
getInitialState() {
return {}
},
componentDidMount() {
fetch("/users/").then(response => {
this.setState(users: response.data)
})
},
render() {
if (this.state.users == undefined) {
return <div />
}
return <div>{this.state.users.map(some_function)}</div>
}
})
The problem is that it's pointless to return empty div
to search engines. I want ajax
request to be finished (even on the server) and render only after that. How can I achieve that?