I have 3 React.js projects and I'm trying to consolidate the reused components across all 3 projects into one shared component library.
This component library is hosted on Github and imported into all 3 projects through the package.json
file like this:
"components": "github:myusername/components"`
I am then able to import the components from the library into each project like such:
import { Form } from "components"
but when the component being imported (in this case a Form
) uses an Apollo/Graphql hook (useQuery
, or useMutation
) I get this error:
Uncaught Invariant Violation: 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.
I've found countless questions about this same error, but the solutions are either already in place or irrelevant. Here is what I've found so far:
- Wrap the App with the
<ApolloProvider client={client}>
tag (this is already there in the 3 projects - but not in the "components" library) - use the
@apollo/client
package instead of the@apollo/react-hooks
- link (already using that package)