Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add working example. #1

Merged
merged 1 commit into from
Feb 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,8 @@ PODS:
- React-jsinspector (0.71.3)
- React-logger (0.71.3):
- glog
- react-native-flipper (0.182.0):
- React-Core
- React-perflogger (0.71.3)
- React-RCTActionSheet (0.71.3):
- React-Core/RCTActionSheetHeaders (= 0.71.3)
Expand Down Expand Up @@ -413,6 +415,8 @@ PODS:
- React-jsi (= 0.71.3)
- React-logger (= 0.71.3)
- React-perflogger (= 0.71.3)
- RealmJS (11.4.0):
- React
- SocketRocket (0.6.0)
- Yoga (1.14.0)
- YogaKit (1.18.1):
Expand Down Expand Up @@ -464,6 +468,7 @@ DEPENDENCIES:
- React-jsiexecutor (from `../node_modules/react-native/ReactCommon/jsiexecutor`)
- React-jsinspector (from `../node_modules/react-native/ReactCommon/jsinspector`)
- React-logger (from `../node_modules/react-native/ReactCommon/logger`)
- react-native-flipper (from `../node_modules/react-native-flipper`)
- React-perflogger (from `../node_modules/react-native/ReactCommon/reactperflogger`)
- React-RCTActionSheet (from `../node_modules/react-native/Libraries/ActionSheetIOS`)
- React-RCTAnimation (from `../node_modules/react-native/Libraries/NativeAnimation`)
Expand All @@ -477,6 +482,7 @@ DEPENDENCIES:
- React-RCTVibration (from `../node_modules/react-native/Libraries/Vibration`)
- React-runtimeexecutor (from `../node_modules/react-native/ReactCommon/runtimeexecutor`)
- ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`)
- RealmJS (from `../node_modules/realm`)
- Yoga (from `../node_modules/react-native/ReactCommon/yoga`)

SPEC REPOS:
Expand Down Expand Up @@ -538,6 +544,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native/ReactCommon/jsinspector"
React-logger:
:path: "../node_modules/react-native/ReactCommon/logger"
react-native-flipper:
:path: "../node_modules/react-native-flipper"
React-perflogger:
:path: "../node_modules/react-native/ReactCommon/reactperflogger"
React-RCTActionSheet:
Expand All @@ -564,6 +572,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native/ReactCommon/runtimeexecutor"
ReactCommon:
:path: "../node_modules/react-native/ReactCommon"
RealmJS:
:path: "../node_modules/realm"
Yoga:
:path: "../node_modules/react-native/ReactCommon/yoga"

Expand Down Expand Up @@ -601,6 +611,7 @@ SPEC CHECKSUMS:
React-jsiexecutor: 515b703d23ffadeac7687bc2d12fb08b90f0aaa1
React-jsinspector: 9f7c9137605e72ca0343db4cea88006cb94856dd
React-logger: 957e5dc96d9dbffc6e0f15e0ee4d2b42829ff207
react-native-flipper: 6e4e344a0104a34a4e189a9ef2b3b5634b516dc8
React-perflogger: af8a3d31546077f42d729b949925cc4549f14def
React-RCTActionSheet: 57cc5adfefbaaf0aae2cf7e10bccd746f2903673
React-RCTAnimation: 11c61e94da700c4dc915cf134513764d87fc5e2b
Expand All @@ -614,6 +625,7 @@ SPEC CHECKSUMS:
React-RCTVibration: 5199a180d04873366a83855de55ac33ce60fe4d5
React-runtimeexecutor: 7bf0dafc7b727d93c8cb94eb00a9d3753c446c3e
ReactCommon: 6f65ea5b7d84deb9e386f670dd11ce499ded7b40
RealmJS: fc807dff0d416153bcfcae0df613b2e93fb14af4
SocketRocket: fccef3f9c5cedea1353a9ef6ada904fde10d6608
Yoga: 5ed1699acbba8863755998a4245daa200ff3817b
YogaKit: f782866e155069a2cca2517aafea43200b01fd5a
Expand Down
44 changes: 40 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
"@realm/react": "^0.4.3",
"react": "18.2.0",
"react-native": "0.71.3",
"realm": "^11.4.0"
"react-native-flipper": "^0.182.0",
"realm": "^11.4.0",
"realm-flipper-plugin-device": "^1.1.0"
},
"devDependencies": {
"@babel/core": "^7.20.0",
Expand Down
63 changes: 31 additions & 32 deletions src/MainScreen.jsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
import { Button,
FlatList,
SafeAreaView,
ScrollView,
StatusBar,
StyleSheet,
Text,
useColorScheme,
View, useCallback} from "react-native"
import TaskContext,{Task} from './DBScheme';
import TaskItem from "./TaskItem";
let realm
function MainScreen(){
import {Button, FlatList, View} from 'react-native';
import React from 'react';
import TaskContext, {Task} from './DBScheme';
import TaskItem from './TaskItem';
import RealmPlugin from 'realm-flipper-plugin-device';

const {useRealm, useQuery, useObject} = TaskContext;
realm = useRealm()
function MainScreen() {
const {useRealm, useQuery, RealmProvider} = TaskContext;
let realm = useRealm();
const tasks = useQuery(Task);

//Add task to realm
Expand Down Expand Up @@ -46,23 +39,29 @@ const deleteData = () =>{

//Added function to clear the db

return (
<View style={{height:100,width:100}}>
<Button title='Add Task' onPress={()=>handleOnPress("dummy string")}></Button>
<Button title="Clear Data" onPress={()=>deleteData()}></Button>
<FlatList
style={{height:1000,width:500,backgroundColor:'red'}}
data={tasks}
keyExtractor={task => task._id.toString()}
renderItem={({item}) => (
<TaskItem
description={item.description}
isComplete={item.isComplete}

return (
<RealmProvider>
<RealmPlugin realms={[realm]} />
<View style={{height: 100, width: 100}}>
<Button
title="Add Task"
onPress={() => handleOnPress('dummy string')}
/>
)}
/>
</View>)
<Button title="Clear Data" onPress={() => deleteData()} />
<FlatList
style={{height: 1000, width: 500, backgroundColor: 'red'}}
data={tasks}
keyExtractor={task => task._id.toString()}
renderItem={({item}) => (
<TaskItem
description={item.description}
isComplete={item.isComplete}
/>
)}
/>
</View>
</RealmProvider>
);
}

export default MainScreen
export default MainScreen;
20 changes: 16 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3610,7 +3610,7 @@
"flatted" "^3.1.0"
"rimraf" "^3.0.2"

"flatted@^3.1.0":
"flatted@^3.1.0", "flatted@^3.2.7":
"integrity" "sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ=="
"resolved" "https://registry.npmjs.org/flatted/-/flatted-3.2.7.tgz"
"version" "3.2.7"
Expand Down Expand Up @@ -6245,12 +6245,17 @@
"jscodeshift" "^0.13.1"
"nullthrows" "^1.1.1"

"react-native-flipper@^0.182.0", "react-native-flipper@>=0.162.0":
"integrity" "sha512-AoLVduVWluY99XDPznn05sXRyrE1OeEkc4aQCxDKgQYfCdf82aNOH+hwGO/CKcGEiC3T9oBzeOofqwo+Og4eWA=="
"resolved" "https://registry.npmjs.org/react-native-flipper/-/react-native-flipper-0.182.0.tgz"
"version" "0.182.0"

"react-native-gradle-plugin@^0.71.15":
"integrity" "sha512-7S3pAuPaQJlhax6EZ4JMsDNpj05TfuzX9gPgWLrFfAIWIFLuJ6aDQYAZy2TEI9QJALPoWrj8LWaqP/DGYh14pw=="
"resolved" "https://registry.npmjs.org/react-native-gradle-plugin/-/react-native-gradle-plugin-0.71.15.tgz"
"version" "0.71.15"

"react-native@>=0.68", "react-native@>=0.70.0", "[email protected]":
"react-native@>=0.68", "react-native@>=0.70.0", "react-native@>0.62.0", "react-native@0.71.3":
"integrity" "sha512-RYJXCcQGa4NTfKiPgl92eRDUuQ6JGDnHqFEzRwJSqEx9lWvlvRRIebstJfurzPDKLQWQrvITR7aI7e09E25mLw=="
"resolved" "https://registry.npmjs.org/react-native/-/react-native-0.71.3.tgz"
"version" "0.71.3"
Expand Down Expand Up @@ -6312,7 +6317,7 @@
"react-shallow-renderer" "^16.15.0"
"scheduler" "^0.23.0"

"react@^16.0.0 || ^17.0.0 || ^18.0.0", "react@^16.8.0 || ^17.0.0 || ^18.0.0", "react@^18.2.0", "react@>=17.0.2", "[email protected]":
"react@^16.0.0 || ^17.0.0 || ^18.0.0", "react@^16.8.0 || ^17.0.0 || ^18.0.0", "react@^18.2.0", "react@>=17", "react@>=17.0.2", "[email protected]":
"integrity" "sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ=="
"resolved" "https://registry.npmjs.org/react/-/react-18.2.0.tgz"
"version" "18.2.0"
Expand Down Expand Up @@ -6359,7 +6364,14 @@
"resolved" "https://registry.npmjs.org/readline/-/readline-1.3.0.tgz"
"version" "1.3.0"

"realm@^11.0.0-rc || ^11.0.0", "realm@^11.4.0":
"realm-flipper-plugin-device@^1.1.0":
"integrity" "sha512-fqajcRm+8K7nUeVi4EUNYtCuVtc+e7GmhME1jKLDKNh3rXoGkvpe8g1j7lgcc8JKmw/V0AeM+N3B4SHQ/Aweng=="
"resolved" "https://registry.npmjs.org/realm-flipper-plugin-device/-/realm-flipper-plugin-device-1.1.0.tgz"
"version" "1.1.0"
dependencies:
"flatted" "^3.2.7"

"realm@^11.0.0-rc || ^11.0.0", "realm@^11.4.0", "realm@>=11.0.0":
"integrity" "sha512-lj8mliQBc+QXJUQI6Fqm45FMWUkXzdHMtdmanMfBMcwUXRDd1YIOQxgArSSL+eE2EOodP3jxNMXhs4bJj/ukdw=="
"resolved" "https://registry.npmjs.org/realm/-/realm-11.4.0.tgz"
"version" "11.4.0"
Expand Down