How to use ApolloProvider with withAuthenticator HOC
See original GitHub issue** Which Category is your question related to? ** Auth, API, aws-amplify-react HoCs
** What AWS Services are you utilizing? ** AppSync, Cognito, Amplify
** Provide additional details e.g. code snippets **
When I try to add the ApolloProvider to my React-based Amplify project, I am met with a slew of errors while trying to compose withAuthenticator
with my own Higher Order Component.
This is probably a noob question, sorry if I’m doing something obviously wrong. (I assume a HoC can nest multiple layers?)
//App.js
/*** class App extends React.Component { ... } ***/
const withAppSyncProvider = (Comp) => {
return class extends React.Component {
render() {
return (
<ApolloProvider client={client}>
<Rehydrated>
<Comp />
</Rehydrated>
</ApolloProvider>
);
}
}
}
export default withAuthenticator(withAppSyncProvider(App));
That code meets with this error:
index.js:1446 Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
Check your code at App.js:103.
in _class (created by class_1)
in class_1 (at src/index.js:12)
Issue Analytics
- State:
- Created 5 years ago
- Comments:12 (3 by maintainers)
Top Results From Across the Web
Get started with Apollo Client - Apollo GraphQL Docs
Step 1: Setup. To start this tutorial, do one of the following: Create a new React project locally with Create React App, or;...
Read more >How to use the aws-amplify-react-native.withAuthenticator ...
Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues...
Read more >React Router withRouter compatibility with AWS AppSync ...
... you to use aws-amplify, is very simple to wrap a react app with authenticator component or withAuthenticator HOC. Take a look here....
Read more >Sviluppare Applicazioni Real Time con AppSync Deck.pptx
The withAuthenticator HOC gives you some nice default authentication screens out-of-box. If you want to use your own components rather then ...
Read more >AWS Amplify Authentication in React Native (Full tutorial)
... project 7:50 Configure Amplify library in our React Native project 9:42 Basic authentication using withAuthenticator () HOC 14:40 AWS ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@jkeys-ecg-nmsu - When I use your import statements, I can reproduce the error.
I am pretty sure that the issue is that you’re trying to import
Rehydrated
from aws-amplify-react. Trying importing it from ‘aws-appsync-react’.@jkeys-ecg-nmsu - We’re happy to leave this open! Please just keep us posted.
For what it’s worth, I used create-react-app as well on my working sample.