Skip to content

Instantly share code, notes, and snippets.

import React from "react";
import { createAppContainer } from "react-navigation";
import Amplify, { Auth } from "aws-amplify";
import { createRootNavigator } from "./router";
import config from "./config";
Amplify.configure({
Auth: {
mandatorySignIn: true,
region: config.AWS.cognito.REGION,
import React from "react";
import { createAppContainer } from "react-navigation";
import Amplify from "aws-amplify";
import { createRootNavigator } from "./router";
import config from "./config";
Amplify.configure({
Auth: {
mandatorySignIn: true,
region: config.AWS.cognito.REGION,
import React from "react";
import {
View,
Text,
StyleSheet,
Button,
TextInput,
TouchableOpacity,
Alert
} from "react-native";
import React from "react";
import {
createStackNavigator,
createBottomTabNavigator,
createSwitchNavigator
} from "react-navigation";
import Signup from "./screens/Signup";
import Login from "./screens/Login";
import Home from "./screens/Home";
$ yarn add aws-amplify
export default {
AWS: {
cognito: {
REGION: "YOUR_COGNITO_REGION",
USER_POOL_ID: "YOUR_COGNITO_USER_POOL_ID",
APP_CLIENT_ID: "YOUR_COGNITO_APP_CLIENT_ID",
IDENTITY_POOL_ID: "YOUR_IDENTITY_POOL_ID"
}
}
};
import React from "react";
import {
Text,
View,
FlatList,
Dimensions
} from "react-native";
const numItems = 10;
const { height, width } = Dimensions.get("window");
class ListsScreen extends React.Component {
state = {
data: [0, 1, 2, 3, 4],
isRefreshing: false
};
refreshData = () => {
this.setState({ isRefreshing: true });
const data = this.state.data.map(x => x * 2);
this.setState({ data, isRefreshing: false });
render() {
return (
<View style={styles.container}>
<FlatList
data={this.state.data}
renderItem={({ item }) => <Text>{`item ${item}`}</Text>}
keyExtractor={(item, index) => `key-${index}`}
/>
</View>
);
import React from "react";
import { Text, View, FlatList } from "react-native";
export default class FlatListDemo extends React.Component {
state = {
data: [0, 1, 2, 3, 4]
};
render() {
return (