Skip to content

Commit a79f267

Browse files
committed
feat: add filter hook
1 parent f839c29 commit a79f267

17 files changed

+230
-349
lines changed

.envrc.example

-2
This file was deleted.

.eslintignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
dist/
22
node_modules/
3-
playground/types/supabase.ts

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
.DS_Store
2-
.envrc
32
.eslintcache
43
dist/
54
node_modules/

.prettierignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
dist/
22
node_modules/
3-
playground/types/supabase.ts
43
yarn.lock

index.html

-13
This file was deleted.

package.json

+4-5
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,12 @@
1212
"license": "MIT",
1313
"scripts": {
1414
"build": "vite build && tsc --emitDeclarationOnly",
15-
"build:watch": "vite build --watch",
15+
"build:watch": "concurrently \"vite build --watch\" \"tsc --emitDeclarationOnly --watch\"",
1616
"clean": "rimraf dist",
17-
"dev": "vite",
18-
"gen": "npx openapi-typescript $VITE_SUPABASE_URL/rest/v1/?apikey=$VITE_SUPABASE_KEY --output playground/types/supabase.ts",
1917
"lint": "eslint . --cache",
2018
"lint:fix": "yarn lint --fix",
2119
"lint:format": "prettier --write .",
2220
"lint:types": "tsc --noEmit",
23-
"predev": "yarn gen",
2421
"prepare": "husky install .config/husky"
2522
},
2623
"peerDependencies": {
@@ -36,6 +33,7 @@
3633
"@types/react": "^17.0.3",
3734
"@typescript-eslint/eslint-plugin": "^4.22.0",
3835
"@typescript-eslint/parser": "^4.22.0",
36+
"concurrently": "^6.0.2",
3937
"eslint": "^7.24.0",
4038
"eslint-config-prettier": "^8.2.0",
4139
"eslint-import-resolver-typescript": "^2.4.0",
@@ -53,5 +51,6 @@
5351
"rimraf": "^3.0.2",
5452
"typescript": "^4.2.4",
5553
"vite": "^2.2.1"
56-
}
54+
},
55+
"dependencies": {}
5756
}

playground/app.tsx

-48
This file was deleted.

playground/favicon.svg

-15
This file was deleted.

playground/main.tsx

-20
This file was deleted.

playground/types/supabase.ts

-193
This file was deleted.

src/hooks/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
export { useFilter } from './use-filter'
12
export { useSelect } from './use-select'

src/hooks/use-filter.ts

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { PostgrestFilterBuilder } from '@supabase/postgrest-js'
2+
import { useCallback } from 'react'
3+
4+
export function useFilter<Data = any>(
5+
filter: (
6+
query: PostgrestFilterBuilder<Data>,
7+
) => PostgrestFilterBuilder<Data>,
8+
deps: any[] = [],
9+
) {
10+
/* eslint-disable react-hooks/exhaustive-deps */
11+
const callback = useCallback(filter, deps)
12+
/* eslint-enable react-hooks/exhaustive-deps */
13+
return callback
14+
}

0 commit comments

Comments
 (0)