Integrating with React Native
You can use Apollo with React Native exactly as you would with React Web.
To introduce Apollo to your app, install React Apollo from npm and use them in your app as outlined in the sample code snippet below:
npm install @apollo/react-hooks apollo-client graphql -save
import React from 'react';
import {AppRegistry} from 'react-native';
import {ApolloClient } from 'apollo-client';
import {ApolloProvider } from '@apollo/react-hooks';
// Create the client as outlined in the setup guide
const client = new ApolloClient();
const App = () => (
<ApolloProvider client={client}>
<MyRootComponent />
</ApolloProvider>
);
AppRegistry.registerComponent('MyApplication', () => App);
Examples
There are some Apollo examples written in React Native that you may wish to refer to:
- The "Hello World" example used at dev.apollodata.com.
- A GitHub API Example built to work with GitHub's new GraphQL API.
Apollo Dev Tools
React Native Debugger supports the Apollo Client Devtools:
- Install React Native Debugger and open it.
- Enable "Debug JS Remotely" in your app.
- (Optional) If you do not see the Developer Tools panel or the Apollo tab is missing in them, toggle the Developer Tools by right clicking anywhere and selecting "Toggle Developer Tools".
Previous:
View integrations
Next:
Integrating with Meteor
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://w3resource.com/apollo-graphql/integrating-with-react-native.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics