You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
when I run the code it gives this error
Possible Unhandled Promise Rejection (id: 0):
Error: Exception in HostFunction: partitionValue must be of type 'string', 'number', 'objectId', or 'null'.
Error: Exception in HostFunction: partitionValue must be of type 'string', 'number', 'objectId', or 'null'.
at exists (native)error many times pl someone help me quick as possible
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I connected my mongodb cloud database with my using app id
and I haves some repeated error
`import React, { useEffect, useState } from 'react';
import { View, Text, TextInput, Button, FlatList, StyleSheet } from 'react-native';
import Realm from 'realm';
const TaskSchema = {
name: 'Task',
properties: {
_id: 'objectId',
title: 'string',
description: 'string',
completed: 'bool',
},
primaryKey: '_id',
};
const appConfig = {
id: '',
timeout: 10000,
};
export const realmApp = new Realm.App(appConfig);
export const realm = async () => {
const user = await realmApp.logIn(Realm.Credentials.anonymous());
const config = {
schema: [TaskSchema],
sync: {
user,
newRealmFileBehavior: {
type: 'openImmediately',
},
existingRealmFileBehavior: {
type: 'downloadBeforeOpen',
},
},
};
return Realm.open(config);
};
const App = () => {
const [tasks, setTasks] = useState([]);
const [newTaskTitle, setNewTaskTitle] = useState('');
const [newTaskDescription, setNewTaskDescription] = useState('');
useEffect(() => {
const getTasks = async () => {
const realmInstance = await realm();
const taskCollection = realmInstance.objects('Task');
setTasks(Array.from(taskCollection));
taskCollection.addListener(() => {
setTasks(Array.from(taskCollection));
});
};
getTasks();
}, []);
const createTask = async () => {
const realmInstance = await realm();
realmInstance.write(() => {
realmInstance.create('Task', {
_id: new Realm.BSON.ObjectId(),
title: newTaskTitle,
description: newTaskDescription,
completed: false,
});
});
setNewTaskTitle('');
setNewTaskDescription('');
};
const toggleTaskCompletion = async (taskId) => {
const realmInstance = await realm();
const task = realmInstance.objectForPrimaryKey('Task', taskId);
realmInstance.write(() => {
task.completed = !task.completed;
});
};
const deleteTask = async (taskId) => {
const realmInstance = await realm();
const task = realmInstance.objectForPrimaryKey('Task', taskId);
realmInstance.write(() => {
realmInstance.delete(task);
});
};
const renderItem = ({ item }) => (
{item.title}
{item.description}
<Button
title={item.completed ? 'Undo' : 'Complete'}
onPress={() => toggleTaskCompletion(item._id)}
/>
<Button title="Delete" onPress={() => deleteTask(item._id)} />
);
return (
Todo App
<TextInput
style={styles.input}
placeholder="Title"
value={newTaskTitle}
onChangeText={(text) => setNewTaskTitle(text)}
/>
<TextInput
style={styles.input}
placeholder="Description"
value={newTaskDescription}
onChangeText={(text) => setNewTaskDescription(text)}
/>
<FlatList
style={styles.taskList}
data={tasks}
renderItem={renderItem}
keyExtractor={(item) => item._id}
/>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
padding: 16,
justifyContent: 'center',
},
title: {
fontSize: 24,
fontWeight: 'bold',
marginBottom: 16,
},
inputContainer: {
marginBottom: 16,
},
input: {
marginBottom: 8,
padding: 8,
borderWidth: 1,
borderColor: 'gray',
},
taskList: {
flexGrow: 1,
},
taskItem: {
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
marginBottom: 8,
padding: 8,
borderWidth: 1,
borderColor: 'gray',
},
});
export default App;
`
when I run the code it gives this error
Possible Unhandled Promise Rejection (id: 0):
Error: Exception in HostFunction: partitionValue must be of type 'string', 'number', 'objectId', or 'null'.
Error: Exception in HostFunction: partitionValue must be of type 'string', 'number', 'objectId', or 'null'.
at exists (native)error many times pl someone help me quick as possible
Beta Was this translation helpful? Give feedback.
All reactions