Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need XHR in component example #17

Open
imShara opened this issue Jul 2, 2015 · 0 comments
Open

Need XHR in component example #17

imShara opened this issue Jul 2, 2015 · 0 comments
Assignees

Comments

@imShara
Copy link

imShara commented Jul 2, 2015

What should isomorphic app make out the box? Complete server rendering. How to make full page render with data from database? With async API request from component before render. Then wait until all data fetched and renderToString().

React Nexus can make something like this but i can't understand how to write this. I don't need to store client stores on server side, but i need just to fetch data on client and on server like it made in react-async, but without fibers.

import React from 'react';
import Async from 'react-async';
import Rx from 'rx';

function defineXHRObservable(url) {
  return {
    id: url,
    start() {
      return Rx.fromPromise(fetch(url))
    }
  }
}

function MyComponentObservables(props) {
  return {
    user: defineXHRObservable(`/api/user?user${props.userID}`)
  }
}

@Async(MyComponentObservables)
class MyComponent extends React.Component {

  render() {
    let {user} = this.props
    ...
  }

}

Can you explain how to make this? Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants