Skip to content

Instantly share code, notes, and snippets.

@seniv
Last active October 21, 2019 19:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seniv/9290a769fdb7e71bf6282109394fcf54 to your computer and use it in GitHub Desktop.
Save seniv/9290a769fdb7e71bf6282109394fcf54 to your computer and use it in GitHub Desktop.
Apollo Client performance
import React from 'react';
import { ApolloProvider, useSubscription } from '@apollo/react-hooks';
import { RootNavigator } from './navigation';
import { client } from './apollo';
import { mySubscription } from './graphql';
function App() {
useSubscription(mySubscription, {
// directly pass instance of apollo client because subscription used
// before ApolloProvider, and client cannot be taken from context
client,
onSubscriptionData: ({ client, subscriptionData }) => { ... }
});
return (
<ApolloProvider client={client}>
<RootNavigator />
</ApolloProvider>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment