Created
July 17, 2019 13:42
-
-
Save bartcis/cf37cf3da534a352a07210b11976c1bb to your computer and use it in GitHub Desktop.
Simple integration of React and Apollo
This file contains hidden or 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 ReactDOM from 'react-dom'; | |
| import './styles/index.css'; | |
| import App from './components/App'; | |
| import * as serviceWorker from './serviceWorker'; | |
| import { ApolloProvider } from 'react-apollo'; | |
| import { ApolloClient } from 'apollo-client'; | |
| import { createHttpLink } from 'apollo-link-http'; | |
| import { InMemoryCache } from 'apollo-cache-inmemory'; | |
| const httpLink = createHttpLink({ | |
| uri: 'http://localhost:4000' | |
| }); | |
| const client = new ApolloClient({ | |
| link: httpLink, | |
| cache: new InMemoryCache() | |
| }); | |
| ReactDOM.render( | |
| <ApolloProvider client={client}> | |
| <App /> | |
| </ApolloProvider>, | |
| document.getElementById('root') | |
| ) | |
| serviceWorker.unregister(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment