amazon-cognito-identity-js
amazon-cognito-identity-js copied to clipboard
Imported modules are undefined with React Native
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.
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
});
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.