Last active
October 21, 2019 19:49
-
-
Save seniv/9290a769fdb7e71bf6282109394fcf54 to your computer and use it in GitHub Desktop.
Apollo Client performance
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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