Skip to content
This repository has been archived by the owner on Mar 15, 2018. It is now read-only.

Multiple requests over different routes. #30

Closed
nickclaw opened this issue Jun 12, 2015 · 2 comments
Closed

Multiple requests over different routes. #30

nickclaw opened this issue Jun 12, 2015 · 2 comments
Assignees
Labels

Comments

@nickclaw
Copy link

I'm using react-router, and I currently have it set up like this.

// code omitted, App and Entry components defined

let AppContainer = Transmit.createContainer(App, {
    queries: {
        entries: function() {
           // code omitted
        }
    }
});

let EntryContainer = Transmit.createContainer(Entry, {
    queries: {
        entry: function(params) {
            // code omitted
        }
    }
});

let routes = (
    <Route handler={AppContainer} path="/">
        <DefaultRoute name="home" handler={ require('./page/home.jsx') } />
        <Route path="/entry/:entry" name="entry" handler={EntryContainer)} />
    </Route>
);

This setup nicely loads the entries query of the outer container on the server side, but the entry query of the inner route only loads client side, is there a way to do this completely on the backend?

@XeeD
Copy link

XeeD commented Jun 15, 2015

Hi, I've implemented it and made some notes about the setup:
https://gist.github.com/XeeD/23824f4626bd29673a44

You need to manually collect the queries of the RouteHandler and them send them in as props. See this: https://gist.github.com/XeeD/23824f4626bd29673a44#file-app-react-js-L24-L37

Hope it helps 😉

@RickWong
Copy link
Owner

RickWong commented Jul 2, 2015

@nickclaw Does entries return a Promise? It should loop through the entries with an index, and actually return Promise.all(entries.map(entry => EntryContainer.getQuery("entry", entry)));. This is a requirement for server-side rendering to render the full page.

@RickWong RickWong closed this as completed Jul 2, 2015
@RickWong RickWong self-assigned this Jul 2, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants