Hey I am creating a messanger using react native, expo and aws amplify this is my a code snipppet from userItem file
import { Auth } from 'aws-amplify';
import { DataStore } from '@aws-amplify/datastore';
import { ChatRoom, User, ChatRoomUser } from '../../src/models';
export default function UserItem({ user }) {
const navigation = useNavigation();
const onPress = async () => {
const newChatRoom = await DataStore.save(new ChatRoom({ newMessages: 0 }));
const authUser = await Auth.currentAuthenticatedUser();
const dbUser = await DataStore.query(User, authUser.attributes.sub);
new ChatRoomUser({
user,
chatroom: newChatRoom,
})
);
navigation.navigate('ChatRoom', { id: newChatRoom.id });
};
return (
<Pressable onPress={onPress} style={styles.container}>
<Image source={{ uri: user.imageUri }} style={styles.image} />
<View style={styles.rightContainer}>
<View style={styles.row}>
<Text style={styles.name}>{user.name}</Text>
</View>
</View>
</Pressable>
);
}
and this is my UserScreen code
import React, { useState, useEffect } from 'react';
import { View, StyleSheet, FlatList } from 'react-native';
import { DataStore } from '@aws-amplify/datastore';
import UserItem from '../components/UserItem';
import { User } from '../src/models';
export default function UsersScreen() {
const [users, setUsers] = useState<User[]>([]);
useEffect(() => {
DataStore.query(User).then(setUsers);
}, []);
return (
<View style={styles.page}>
<FlatList
data={users}
renderItem={({ item }) => <UserItem user={item} />}
showsVerticalScrollIndicator={false}
/>
</View>
);
}
but I am getting 2 message in console
INFO] 37:36.850 Reachability - subscribing to reachability in React Native
[INFO] 37:37.118 Reachability - Notifying reachability change true
Possible Unhandled Promise Rejection (id: 0):
Object {
"data": Object {
"syncUsers": null,
},
"errors": Array [
Object {
"locations": null,
"message": "Cannot return null for non-nullable type: 'AWSDateTime' within parent 'User' (/syncUsers/items[0]/createdAt)",
I have tried deleting my users from DynamoDb and then added new users in it but the error persists. I think I have to reset my aws-amplify json file but I do not how.