@triplit/react 0.0.27 → 0.0.29

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # @triplit/react
2
2
 
3
+ ## 0.0.28
4
+
5
+ ### Patch Changes
6
+
7
+ - 5011219: - add string comparison operations
8
+ - add fetchById method
9
+ - support cursor pagination
10
+ - performance improvements and bug fixes
11
+ - Updated dependencies [5011219]
12
+ - @triplit/client@0.0.28
13
+
3
14
  ## 0.0.27
4
15
 
5
16
  ### Patch Changes
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{useEffect as y,useState as u}from"react";function d(e,s){let[i,n]=u(void 0),[l,t]=u(!1),r=s.build(),o=JSON.stringify(r);return y(()=>{t(!0);let f=e.subscribe(r,c=>{t(!1),n(c)});return()=>{f()}},[o,e]),{fetchingLocal:l,results:i,error:null}}export{d as useQuery};
1
+ export * from './use-query';
@@ -0,0 +1,25 @@
1
+ import { useEffect, useState } from 'react';
2
+ export function useQuery(client, query) {
3
+ const [results, setResults] = useState(undefined);
4
+ const [fetchingLocal, setFetchingLocal] = useState(false);
5
+ // const [fetchingRemote, setFetchingRemote] = useState(false);
6
+ const builtQuery = query.build();
7
+ const stringifiedQuery = JSON.stringify(builtQuery);
8
+ useEffect(() => {
9
+ setResults(undefined);
10
+ setFetchingLocal(true);
11
+ const unsubscribe = client.subscribe(builtQuery, (localResults) => {
12
+ setFetchingLocal(false);
13
+ setResults(localResults);
14
+ });
15
+ return () => {
16
+ unsubscribe();
17
+ };
18
+ }, [stringifiedQuery, client]);
19
+ return {
20
+ fetchingLocal,
21
+ // fetchingRemote,
22
+ results,
23
+ error: null,
24
+ };
25
+ }
package/package.json CHANGED
@@ -1,22 +1,20 @@
1
1
  {
2
2
  "name": "@triplit/react",
3
3
  "packageManager": "yarn@3.4.1",
4
- "version": "0.0.27",
4
+ "version": "0.0.29",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
7
7
  "type": "module",
8
8
  "scripts": {
9
- "build": "yarn build:code && yarn build:types",
10
- "build:code": "node build.cjs",
11
- "build:types": "tsc --noEmit false --emitDeclarationOnly --declaration --baseUrl . --outDir dist",
9
+ "build": "tsc --noEmit false --declaration --baseUrl . --paths null --outDir dist",
12
10
  "lint": "tsc",
13
- "publish-pkg": "yarn npm publish --access public"
11
+ "publish-pkg": "node ../../scripts/npm-check-version-and-publish.js"
14
12
  },
15
13
  "files": [
16
14
  "/dist"
17
15
  ],
18
16
  "dependencies": {
19
- "@triplit/client": "^0.0.27"
17
+ "@triplit/client": "^0.0.29"
20
18
  },
21
19
  "devDependencies": {
22
20
  "@types/react": "^18.2.0",