Skip to content

Commit 3e7a1ca

Browse files
committed
chore: clean up docs
1 parent 654bc7f commit 3e7a1ca

File tree

8 files changed

+27
-28
lines changed

8 files changed

+27
-28
lines changed

README.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,19 @@ const App = () => (
3333
)
3434
```
3535

36-
Now every component inside and under the `Provider` can use the Supabase client:
36+
Now every component inside and under the `Provider` can use the Supabase client and hooks:
3737

3838
```js
39-
import { useSelect } from 'react-supabase'
39+
import { useRealtime } from 'react-supabase'
4040

4141
const Todos = () => {
42-
const [result, reexecuteSelect] = useSelect('todos')
42+
const [result, reexecute] = useRealtime('todos')
4343

4444
const { data, fetching, error } = result
4545

4646
if (fetching) return <p>Loading...</p>
4747
if (error) return <p>Oh no... {error.message}</p>
48+
4849
return (
4950
<ul>
5051
{data.map((todo) => (

docs/pages/documentation/data/use-delete.md

+6-9
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Performs DELETE on table.
66
import { useDelete } from 'react-supabase'
77

88
function Page() {
9-
const [{ count, data, error, fetching }, deleteTodos] = useDelete('todos')
9+
const [{ count, data, error, fetching }, execute] = useDelete('todos')
1010

1111
async function onClickDelete(id) {
1212
const { count, data, error } = await deleteTodos(
@@ -25,7 +25,7 @@ Throws error during execute if a filter is not passed during hook initialization
2525
During hook initialization:
2626

2727
```js
28-
const [{ count, data, error, fetching }, deleteTodos] = useDelete('todos', {
28+
const [{ count, data, error, fetching }, execute] = useDelete('todos', {
2929
filter: (query) => query.eq('status', 'completed'),
3030
options: {
3131
returning: 'represenation',
@@ -37,11 +37,8 @@ const [{ count, data, error, fetching }, deleteTodos] = useDelete('todos', {
3737
Or execute function:
3838

3939
```js
40-
const { count, data, error } = await deleteTodos(
41-
(query) => query.eq('id', id),
42-
{
43-
returning: 'minimal',
44-
count: 'estimated',
45-
},
46-
)
40+
const { count, data, error } = await execute((query) => query.eq('id', id), {
41+
returning: 'minimal',
42+
count: 'estimated',
43+
})
4744
```

docs/pages/documentation/data/use-insert.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Performs INSERT into table.
66
import { useInsert } from 'react-supabase'
77

88
function Page() {
9-
const [{ count, data, error, fetching }, insertTodos] = useInsert('todos')
9+
const [{ count, data, error, fetching }, execute] = useInsert('todos')
1010

1111
async function onClickInsert(name) {
1212
const { count, data, error } = await insertTodos({
@@ -23,7 +23,7 @@ function Page() {
2323
During hook initialization:
2424

2525
```js
26-
const [{ count, data, error, fetching }, insertTodos] = useInsert('todos', {
26+
const [{ count, data, error, fetching }, execute] = useInsert('todos', {
2727
options: {
2828
returning: 'represenation',
2929
count: 'exact',
@@ -34,7 +34,7 @@ const [{ count, data, error, fetching }, insertTodos] = useInsert('todos', {
3434
Or execute function:
3535

3636
```js
37-
const { count, data, error } = await insertTodos(
37+
const { count, data, error } = await execute(
3838
{ name: 'Buy more cheese' },
3939
{
4040
count: 'estimated',

docs/pages/documentation/data/use-select.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Performs vertical filtering with SELECT.
66
import { useSelect } from 'react-supabase'
77

88
function Page() {
9-
const [{ count, data, error, fetching }, selectTodos] = useSelect('todos')
9+
const [{ count, data, error, fetching }, reexecute] = useSelect('todos')
1010

1111
if (error) return <div>{error.message}</div>
1212
if (fetching) return <div>Loading todos</div>
@@ -21,7 +21,7 @@ function Page() {
2121
During hook initialization:
2222
2323
```js
24-
const [{ count, data, error, fetching }, selectTodos] = useSelect('todos', {
24+
const [{ count, data, error, fetching }, reexecute] = useSelect('todos', {
2525
columns: 'id, name, description',
2626
filter: (query) => query.eq('status', 'completed'),
2727
options: {
@@ -47,7 +47,7 @@ function Page() {
4747
(query) => query.eq('status', status),
4848
[status],
4949
)
50-
const [{ data }] = useSelect('todos', { filter })
50+
const [result, reexecute] = useSelect('todos', { filter })
5151

5252
return ...
5353
}

docs/pages/documentation/data/use-update.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ Performs UPDATE on table.
66
import { useUpdate } from 'react-supabase'
77

88
function Page() {
9-
const [{ count, data, error, fetching }, updateTodos] = useUpdate('todos')
9+
const [{ count, data, error, fetching }, execute] = useUpdate('todos')
1010

1111
async function onClickMarkAllComplete() {
12-
const { count, data, error } = await updateTodos(
12+
const { count, data, error } = await execute(
1313
{ completed: true },
1414
(query) => query.eq('completed', false),
1515
)
@@ -26,7 +26,7 @@ Throws error during execute if a filter is not passed during hook initialization
2626
During hook initialization:
2727

2828
```js
29-
const [{ count, data, error, fetching }, updateTodos] = useUpdate('todos', {
29+
const [{ count, data, error, fetching }, execute] = useUpdate('todos', {
3030
filter: (query) => query.eq('completed', false),
3131
options: {
3232
returning: 'represenation',
@@ -38,7 +38,7 @@ const [{ count, data, error, fetching }, updateTodos] = useUpdate('todos', {
3838
Or execute function:
3939

4040
```js
41-
const { count, data, error } = await updateTodos(
41+
const { count, data, error } = await execute(
4242
{ completed: true },
4343
(query) => query.eq('completed', false),
4444
{

docs/pages/documentation/realtime/use-realtime.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Fetch table and listen for changes.
66
import { useRealtime } from 'react-supabase'
77

88
function Page() {
9-
const [{ data, error, fetching }, refresh] = useRealtime('todos')
9+
const [{ data, error, fetching }, reexecute] = useRealtime('todos')
1010

1111
return ...
1212
}
@@ -22,7 +22,7 @@ When using your own compare function, you typically want to compare unique value
2222
import { useRealtime } from 'react-supabase'
2323

2424
function Page() {
25-
const [{ data, error, fetching }, refresh] = useRealtime(
25+
const [result, reexecute] = useRealtime(
2626
'todos',
2727
(data, payload) => data.username === payload.username,
2828
)

docs/pages/getting-started.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,19 @@ const App = () => (
2525
)
2626
```
2727

28-
Now every component inside and under the `Provider` can use the Supabase client (`useClient`) and related hooks (`useSelect`, `useSignIn`, `useSubscription`, etc.):
28+
Now every component inside and under the `Provider` can use the Supabase client and hooks:
2929

3030
```js
31-
import { useSelect } from 'react-supabase'
31+
import { useRealtime } from 'react-supabase'
3232

3333
const Todos = () => {
34-
const [result, reexecuteSelect] = useSelect('todos')
34+
const [result, reexecute] = useRealtime('todos')
3535

3636
const { data, fetching, error } = result
3737

3838
if (fetching) return <p>Loading...</p>
3939
if (error) return <p>Oh no... {error.message}</p>
40+
4041
return (
4142
<ul>
4243
{data.map((todo) => (

docs/pages/recipes/use-auth.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import { AuthContext } from 'path/to/auth/context'
3434

3535
export function useAuth() {
3636
const context = useContext(AuthContext)
37-
if (context === undefined) {
37+
if (context === undefined)
3838
throw Error('useAuth must be used within AuthProvider')
3939
return context
4040
}

0 commit comments

Comments
 (0)