forked from software-mansion-labs/reanimated-3-playground
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathScreen.js
47 lines (43 loc) · 1009 Bytes
/
Screen.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import {View, Button} from 'react-native';
import React from 'react';
import Realm from 'realm';
const TaskSchema = {
name: 'Task',
properties: {
_id: 'int',
name: 'string',
status: 'string?',
},
primaryKey: '_id',
};
export default function AnimatedStyleUpdateExample(props) {
const handleWrite = async () => {
try {
const realm = await Realm.open({
path: 'myrealm',
schema: [TaskSchema],
});
let task1, task2;
realm.write(() => {
task1 = realm.create('Task', {
_id: 1,
name: 'go grocery shopping',
status: 'Open',
});
task2 = realm.create('Task', {
_id: 2,
name: 'go exercise',
status: 'Open',
});
console.log(`created two tasks: ${task1.name} & ${task2.name}`);
});
} catch (e) {
console.error('EEEE', e);
}
};
return (
<View>
<Button title="write to realm" onPress={handleWrite} />
</View>
);
}