amplify-js: Amplify.configure manual setup broken

Describe the bug Cannot use aws-amplify to login with latest react-native version due to t.getPromise error on release builds and cannot update aws-amplify library due to Amplify.configure not working!

To Reproduce Steps to reproduce the behavior:

In a react-native application create config like follows:

const config = {
  Auth: {
    identityPoolId: 'XXX...',
    region: 'XXX...',
    userPoolId: 'XXX...',
    userPoolWebClientId: 'XXX...',
    mandatorySignIn: false,
  },
}

export default config

Import into App.js and configure

Amplify.configure(awsConfig)

Auth userPool is null and cannot use Auth.

In latest react-native release, cannot login with the above on aws-amplify 1.0.0 due to t.getPromise error.

Expected behavior Configure should be able to authenticate and userPool should be defined.

Smartphone (please complete the following information):

  • Mobile iOS/android applications
  • aws-amplify@1.1.3
  • react-native 0.57

Additional context I can configure Auth directly, but Cache not defined and not working. Works on aws-amplify 1.0.0 but have a t.getPromise error for all login on release build with that version.

NOTE: We user our own components, not aws-amplify-react-native.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 3
  • Comments: 30 (10 by maintainers)

Most upvoted comments

This looks to be resolved with at least the latest version.

@strykerCrew I tried to reproduce in my local environment with a blank react-native app. Here is my package.json:

{
  "name": "myapp_rn",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "aws-amplify": "^1.1.4",
    "react": "16.4.1",
    "react-native": "0.56.0"
  },
  "devDependencies": {
    "babel-jest": "23.4.0",
    "babel-preset-react-native": "^5",
    "jest": "23.4.1",
    "react-test-renderer": "16.4.1"
  },
  "jest": {
    "preset": "react-native"
  }
}

and this is my App.js:

/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 *
 * @format
 * @flow
 */

import React, {Component} from 'react';
import {Platform, StyleSheet, Text, View, Button} from 'react-native';

import Amplify, { Auth } from 'aws-amplify';

window.LOG_LEVEL = 'DEBUG';
Amplify.configure({
  Auth: {
    identityPoolId: 'xxxx',
    mandatorySignIn: true,
    region: 'us-east-1',
    userPoolId: 'xxxx',
    userPoolWebClientId: 'xxxx'
  }
  
});

const instructions = Platform.select({
  ios: 'Press Cmd+R to reload,\n' + 'Cmd+D or shake for dev menu',
  android:
    'Double tap R on your keyboard to reload,\n' +
    'Shake or press menu button for dev menu',
});

type Props = {};
class App2 extends Component<Props> {

  constructor(props) {
    super(props);

    this.state = {
      text: 'empty'
    };
    this.test = this.test.bind(this);
    this.cleanText = this.cleanText.bind(this);
  }

  async test() {
    console.log(Auth.configure());
    this.setState({
        text: ''+JSON.stringify(Auth.configure())
    });

    try {
        // just for testing
        const user = await Auth.signIn(username, password);
        console.log(user);
    } catch (e) {
        console.log(e);
    }
  }

  async cleanText() {
    this.setState({text: 'empty'});
  }

  render() {
    return (
      <View style={styles.container}>
         <Button
            title='test api'
            onPress={this.test}
        />
        <Button
            title='clean text'
            onPress={this.cleanText}
        />
        <Text>
          {this.state.text}
        </Text> 
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },
  welcome: {
    fontSize: 20,
    textAlign: 'center',
    margin: 10,
  },
  instructions: {
    textAlign: 'center',
    color: '#333333',
    marginBottom: 5,
  },
});

export default App2;

Tested both in development mode and release mode and no error found by far. I doubt there maybe something related to react-native@0.57.1 but I couldn’t build a blank app with that version I don’t know why.