amazon-cognito-identity-js icon indicating copy to clipboard operation
amazon-cognito-identity-js copied to clipboard

Imported modules are undefined with React Native

Open brianfitzgerald opened this issue 7 years ago • 2 comments

I am working with react-native 0.5. To install, I did an npm install amazon-cognito-identity-js and ran react-native link amazon-cognito-identity-js.

I am importing the modules like this: import { CognitoUserPool, AuthenticationDetails, CognitoUser } from 'amazon-cognito-identity-js'

However, when I run the app, and I console.log(AuthenticationDetails), it comes back as undefined. I also get the error that AuthenticationDetails is not a function when I try to implement the sample code.

Did I miss a step? I've lost a day on trying to debug this, and it's completely confounded me.

brianfitzgerald avatar Dec 29 '17 00:12 brianfitzgerald

Perhaps your initializing it incorrectly? Below is how I use it;

import {
  AuthenticationDetails,
  CognitoUser,
  CognitoUserPool,
  CognitoUserAttribute
} from 'react-native-aws-cognito-js';

...
const authenticationDetails = new AuthenticationDetails({
        Username: username,
        Password: password
      });

kpolley avatar Dec 29 '17 17:12 kpolley

I copy-pasted your import statement directly, and I'm still seeing the same error. The console.log is still returning undefined. It looks like the files are linked correctly in Xcode, as well.

brianfitzgerald avatar Dec 30 '17 05:12 brianfitzgerald