daff laff
daff laff

Reputation: 29

Can't spot my syntax error in React Native?

I'm trying to create a table in DynamoDB but the thing is, why am I getting an error that says I'm missing a , in my code. I've tried placing it next at the end of the .createTable() method and at the end of .init() method but even that doesn't work.

Here's my .js file:

// 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

Upvotes: 0

Views: 84

Answers (1)

Anthony
Anthony

Reputation: 6482

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));
}

is missing an ending )

Upvotes: 4

Related Questions