Skip to content

Commit 8c53cb2

Browse files
authored
React native fix and README (#6)
1 parent 52ccffc commit 8c53cb2

File tree

8 files changed

+100
-56
lines changed

8 files changed

+100
-56
lines changed

examples/next-ts-todo/package-lock.json

Lines changed: 0 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/react-ts-todo/package-lock.json

Lines changed: 0 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
"license": "MIT",
55
"scripts": {
66
"clean": "lerna clean --yes && rm -r node_modules",
7-
"postinstall": "lerna bootstrap",
7+
"bootstrap": "lerna bootstrap",
8+
"build": "lerna run build --scope '@parse/*' --stream",
9+
"postinstall": "npm run bootstrap && npm run build",
810
"dev-parse-react-base": "lerna run dev --scope @parse/react-base --stream",
911
"dev-parse-react": "lerna run dev --scope @parse/react --stream",
1012
"dev-parse-react-native": "lerna run dev --scope @parse/react-native --stream",

packages/parse-react-base/package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,11 @@
2424
"main": "dist/index.js",
2525
"types": "dist/index.d.ts",
2626
"files": [
27-
"dist",
28-
"src"
27+
"dist"
2928
],
3029
"scripts": {
3130
"dev": "tsc --build ./tsconfig.json --watch",
32-
"build": "tsc --build ./tsconfig.json",
33-
"postinstall": "npm run build"
31+
"build": "tsc --build ./tsconfig.json"
3432
},
3533
"peerDependencies": {
3634
"parse": ">= 2.17.0",

packages/parse-react-native/README.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,92 @@
1515
<img alt="NPM Version" src="https://badge.fury.io/js/%40parse%2Freact-native.svg" />
1616
</a>
1717
</p>
18+
19+
# Getting Started
20+
21+
First, install the [parse](https://www.npmjs.com/package/parse) and [@parse/react-native](https://www.npmjs.com/package/@parse/react-native) npm modules into your react-native application.
22+
23+
```sh
24+
npm install parse @parse/react-native --save
25+
```
26+
27+
In your `App.js` file, import and initialize Parse:
28+
29+
```js
30+
import { initializeParse } from '@parse/react-native';
31+
32+
initializeParse(
33+
'YOUR_SERVER_URL',
34+
'YOUR_APPLICATION_ID',
35+
'YOUR_JAVASCRIPT_KEY'
36+
);
37+
```
38+
39+
Now you are ready to use a Parse Query:
40+
41+
```js
42+
import { useParseQuery } from '@parse/react-native';
43+
44+
const SomeComponent = () => {
45+
const parseQuery = new Parse.Query('SomeClass');
46+
47+
const {
48+
isLive, // Indicates that Parse Live Query is connected
49+
isLoading, // Indicates that the initial load is being processed
50+
isSyncing, // Indicates that the library is getting the latest data from Parse Server
51+
results, // Stores the current results
52+
count, // Stores the current results count
53+
error, // Stores any error
54+
reload // Function that can be used to reload the data
55+
} = useParseQuery(parseQuery);
56+
57+
return (
58+
<View>
59+
{isLoading && (
60+
<View>
61+
<Text>Loading...</Text>
62+
</View>
63+
)}
64+
{isLive && (
65+
<View>
66+
<Text>Live!</Text>
67+
</View>
68+
)}
69+
{isSyncing && (
70+
<View>
71+
<Text>Syncing...</Text>
72+
</View>
73+
)}
74+
{results && (
75+
<View>
76+
{results.map(result => (
77+
<View>
78+
<Text key={result.id}>
79+
{result.get('someField')}
80+
</Text>
81+
</View>
82+
))}
83+
</View>
84+
)}
85+
<View>
86+
<Text>{count}</Text>
87+
</View>
88+
{error && (
89+
<View>
90+
<Text>{error.message}</Text>
91+
</View>
92+
)}
93+
<View>
94+
<Button
95+
onPress={reload}
96+
title="Reload"
97+
/>
98+
</View>
99+
</View>
100+
);
101+
};
102+
```
103+
104+
# Example
105+
106+
See a [Todo List Example](https://github.com/parse-community/parse-react/tree/master/examples/react-native-ts-todo).

packages/parse-react-native/package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,11 @@
2121
"main": "dist/index.js",
2222
"types": "dist/index.d.ts",
2323
"files": [
24-
"dist",
25-
"src"
24+
"dist"
2625
],
2726
"scripts": {
2827
"dev": "tsc --build ./tsconfig.json --watch",
29-
"build": "tsc --build ./tsconfig.json",
30-
"postinstall": "npm run build"
28+
"build": "tsc --build ./tsconfig.json"
3129
},
3230
"peerDependencies": {
3331
"parse": ">= 2.17.0",

packages/parse-react-ssr/package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,11 @@
2121
"main": "dist/index.js",
2222
"types": "dist/index.d.ts",
2323
"files": [
24-
"dist",
25-
"src"
24+
"dist"
2625
],
2726
"scripts": {
2827
"dev": "tsc --build ./tsconfig.json --watch",
29-
"build": "tsc --build ./tsconfig.json",
30-
"postinstall": "npm run build"
28+
"build": "tsc --build ./tsconfig.json"
3129
},
3230
"peerDependencies": {
3331
"parse": ">= 2.17.0",

packages/parse-react/package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,11 @@
2121
"main": "dist/index.js",
2222
"types": "dist/index.d.ts",
2323
"files": [
24-
"dist",
25-
"src"
24+
"dist"
2625
],
2726
"scripts": {
2827
"dev": "tsc --build ./tsconfig.json --watch",
29-
"build": "tsc --build ./tsconfig.json",
30-
"postinstall": "npm run build"
28+
"build": "tsc --build ./tsconfig.json"
3129
},
3230
"peerDependencies": {
3331
"parse": ">= 2.17.0",

0 commit comments

Comments
 (0)