javascript - 无法在 React Native 中发现我的语法错误?

标签 javascript ios reactjs react-native amazon-dynamodb

我正在尝试在 DynamoDB 中创建一个表,但问题是,为什么我收到一个错误,提示我在我的代码中缺少一个 ,。我试过将它放在 .createTable() 方法的末尾和 .init() 方法的末尾,但即使这样也行不通。

这是我的 .js 文件:

// Partition key = "user_id"
// Table name = "user_choice"

import React, { Component } from 'react';
import { connect } from 'react-redux';
import { ScrollView, Text, View, Button } from 'react-native';
import { logout } from '../redux/actions/auth';
import DropdownMenu from 'react-native-dropdown-menu';
import Icon from './Icon';
import {DynamoDB} from 'react-native-dynamodb';

let dynamodb = DynamoDB.init({
    credentials: {
        AccessKeyId: 'Something',
        SecretKey: 'Something'
    }
    // region: 'us-east-1' - default, optional
    // version: '20120810' - default, optional
})

dynamodb.createTable(params, function(err, data) {
    console.error("Unable to create table. Error JSON:", JSON.stringify(err, null, 2));
    console.log("Created table. Table description JSON:", JSON.stringify(data, null, 2));
}

class Secured extends Component {
    render() {
        var data = [["Something"], ["Something"], ["Something"], ["Something"]];

        return(
            <ScrollView style={{padding: 20}}>
                <Icon/>

                <Text style={{fontSize: 27}}>
                    {`Welcome ${this.props.username}`}
                </Text>

                <View style={{flex: 1}}>

                    <DropdownMenu style={{flex: 1}}
                                  bgColor={"purple"}  //the background color of the head, default is grey
                                  tintColor={"white"} //the text color of the head, default is white
                                  selectItemColor={"orange"} //the text color of the selected item, default is red
                                  data={data}
                                  maxHeight={410}  // the max height of the menu
                                  handler={(selection, row) => alert(data[selection][row])} >

                        <View style={{flex: 1, alignItems: 'center', justifyContent: 'center'}} >
                        </View>
                    </DropdownMenu>

                </View>

                <View style={{margin: 20}}/>

                <Button onPress={(e) => this.userLogout(e)} title="Logout"/>

            </ScrollView>
        );
    }
}

const mapStateToProps = (state, ownProps) => {
    return {
        username: state.auth.username
    };
}

const mapDispatchToProps = (dispatch) => {
    return {
        onLogout: () => { dispatch(logout()); }
    }
}

export default connect(mapStateToProps, mapDispatchToProps)(Secured);

enter image description here

最佳答案

dynamodb.createTable(params, function(err, data) {
    console.error("Unable to create table. Error JSON:", JSON.stringify(err, null, 2));
    console.log("Created table. Table description JSON:", JSON.stringify(data, null, 2));
}

缺少结尾 )

关于javascript - 无法在 React Native 中发现我的语法错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45309716/

相关文章:

javascript - 访问潜在 null/ undefined variable 的属性 - javascript

javascript - 如何在 react 中对多个数组进行过滤

javascript - 映射迭代器未定义 React.JS

javascript - 无法在 JS 而不是 HTML 中初始化 ng-model

javascript - 来自 URI 源的图像未显示在 React Native 中

javascript - jQuery/Javascript 使用 for 循环将数字 id 添加到两个元素

iOS - 将 View 锚定到屏幕顶部,状态栏后面

ios - OSX UIGraphicsBeginImageContext

ios - 在应用程序中转发通信

reactjs - 如何在微前端架构中共享 redux store?