Reputation: 566
I'm developing a web site with React and Apollo but throw the error. I saw that can be something about hierarchy
Could not find "client" in the context or passed in as an option. Wrap the root component in an <ApolloProvider>, or pass an ApolloClient instance in via options.
import React from 'react';
import ReactDOM from 'react-dom';
import { ApolloProvider } from 'react-apollo';
import graphqlClient from './services/graphql';
import App from './App';
import 'bootstrap/dist/css/bootstrap.min.css';
ReactDOM.render(
<ApolloProvider client={graphqlClient}>
<App />,
</ApolloProvider>,
document.getElementById('root'),
);
import React from 'react';
import { BrowserRouter as Router } from 'react-router-dom';
import GlobalStyle from './styles/global';
import Routes from './routes';
const App: React.FC = () => {
return (
<Router>
<Routes />
<GlobalStyle />
</Router>
);
};
export default App;
Upvotes: 0
Views: 577
Reputation: 119
Make sure you have correctly set up the apollo client in "./services/graphql". For more information I have to take a look on that module.
You use previous apollo client. If you start a new project, better to start with the latest one. https://www.apollographql.com/docs/react/
Upvotes: 1