question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 5 years ago
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
haverchuckcommented, Feb 22, 2019

@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’.

1reaction
haverchuckcommented, Feb 19, 2019

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found