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

Server Side Rendering #417

Open
signalwerk opened this issue Oct 23, 2018 · 0 comments
Open

Server Side Rendering #417

signalwerk opened this issue Oct 23, 2018 · 0 comments

Comments

@signalwerk
Copy link
Contributor

If I fetch something from the GraphQL-Server I get from the Server-Side-Rendering <div>loading...</div> instead of my data. Any idea how to make the SSR waiting for the data?

// home.jsx
...
import query from "./query.gql";
import withApollo from "~/shared/withApollo";

export const Home: StatelessComponent<{}> = ({ loading, entities }) => {
  console.log('entities', entities)

  if (loading) {
    return <div>loading...</div>;
  }

  return (
    <div>{entities.map(item => "...")}</div>
  );
};

const withQuery = graphql(query, {
  props: ({ ownProps, data }) => ({
    ...ownProps,
    entities: data.nodeQuery && data.nodeQuery.entities,
    loading: data.loading
  })
});

// export default Home;
export default compose(withApollo, withQuery)(Home);
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

1 participant