Skip to content

Commit

Permalink
Merge pull request #3 from morrys/hooks
Browse files Browse the repository at this point in the history
Hooks
  • Loading branch information
morrys authored May 18, 2019
2 parents 4da2a7d + b4d1752 commit 473c597
Show file tree
Hide file tree
Showing 9 changed files with 287 additions and 500 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const network = Network.create(fetchQuery);
const storeOffline = OfflineStore(network);
const source = new RecordSource(storeOffline);
const store = new Store(storeOffline, source);
const modernEnvironment = new Environment({ network, store, dataFrom: "CACHE_FIRST" }, storeOffline);
const modernEnvironment = new Environment({ network, store }, storeOffline);
```

Change the renderer
Expand All @@ -58,7 +58,7 @@ const network = Network.create(fetchQuery);
const storeOffline = OfflineStore(network);
const source = new RecordSource(storeOffline);
const store = new Store(storeOffline, source);
const modernEnvironment = new Environment({ network, store, dataFrom: "CACHE_FIRST" }, storeOffline);
const modernEnvironment = new Environment({ network, store }, storeOffline);
```

Change the renderer
Expand Down Expand Up @@ -94,6 +94,7 @@ It is possible to customize the offline store through these parameters:

* Add "LoadingComponent" property
* Add "cached" property in render function
* Add CACHE_FIRST in dataFrom, with this property the query is not executed on the network if it finds valid results in the cache

```
<QueryRenderer
Expand All @@ -104,6 +105,11 @@ It is possible to customize the offline store through these parameters:
render={({ props, error, retry, cached }) => {
```

## Hooks

```
const hooksProps = useQuery(props);
```

## Requirement

Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-relay-offline",
"version": "0.1.3",
"version": "0.2.0",
"keywords": [
"graphql",
"relay",
Expand Down Expand Up @@ -32,12 +32,12 @@
"uuid": "3.3.2"
},
"peerDependencies": {
"react": "^16.5.0",
"react": ">=16.8.0",
"react-relay": "^3.0.0 || ^4.0.0"
},
"devDependencies": {
"typescript": "3.1.1",
"react": "16.6.3",
"react": "16.8.6",
"@types/react": "16.8.14",
"@types/react-dom": "16.8.4",
"react-relay": "^4.0.0"
Expand Down
Loading

0 comments on commit 473c597

Please sign in to comment.