What reexecute means? #10
Unanswered
cdedreuille
asked this question in
Q&A
Replies: 1 comment 5 replies
-
import { useSelect } from 'react-supabase'
function Page() {
const [{ count, data, error, fetching }, reexecute] = useSelect('todos')
const refresh = async () => {
const res = await reexecute()
// can access response properties: res.data, res.error, etc.
}
if (error) return <div>{error.message}</div>
if (fetching) return <div>Loading todos</div>
if (data?.length === 0) return <div>No todos</div>
return <>
<button onClick={refresh}>Refresh</button>
{/* display todos with `data.map` */}
<>
} You can also assign a different name instead of const [, fetchTodos] = useSelect('todos') |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
First of all, thanks for building this project. This is great.
I'm a bit confused about the meaning of
reexecute
in this structureconst [{ count, data, error, fetching }, reexecute] = useSelect('todos')
.Is this just a function to fetch the data again? Any documentation or example on where this could be useful?
Thanks
Beta Was this translation helpful? Give feedback.
All reactions