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.

Amplify.configure manual setup broken

See original GitHub issue

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.

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
strykerCrewcommented, Dec 6, 2018

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

1reaction
powerful23commented, Sep 27, 2018

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configuring build settings - AWS Amplify Hosting
You can configure Amplify to disable automatic builds on every code commit. To set up, choose App settings, General, and then scroll to...
Read more >
Is it possible to use the amplify framework without using the cli?
You can find the manual configuration in the Amplify documentation for each library you plan to use. Here is an example using Cognito:...
Read more >
Client configuration - JavaScript - AWS Amplify Docs
The Amplify.configure() configuration can generally be included in your project ... (optional) - Manually set key value pairs that can be passed to...
Read more >
amplify-js
x.x has breaking changes. Please see the breaking changes below: AWS.credentials and AWS.config don't exist anymore in Amplify JavaScript.
Read more >
How to Build a Full Stack App with AWS Amplify and React
With that set up we can now install Amplify and then configure it. npm install -g @aws-amplify/cli amplify configure.
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