amazon-archives / amazon-cognito-identity-js

Amazon Cognito Identity SDK for JavaScript
Other
985 stars 454 forks source link

Imported modules are undefined with React Native #638

Open brianfitzgerald opened 6 years ago

brianfitzgerald commented 6 years ago

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.

kpolley commented 6 years ago

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
      });
brianfitzgerald commented 6 years ago

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.