mirror of
https://github.com/supabase/supabase.git
synced 2026-10-10 11:55:05 +03:00
docs: use createResource instead of signal+effect
Replace bad practice way of fetching data. Ideally It’d be a solidstart `server$` function, but for solid this is the way.
This commit is contained in:
1 parent
6961e340bb
commit
b5d288a0be
1 file changed
+7
-11
@@ -87,21 +87,17 @@ export const meta = {
|
||||
|
||||
```jsx src/App.jsx
|
||||
import { createClient } from "@supabase/supabase-js";
|
||||
import { createEffect, createSignal, For } from "solid-js";
|
||||
import { createResource, For } from "solid-js";
|
||||
|
||||
const supabase = createClient('https://<project>.supabase.co', '<your-anon-key>');
|
||||
|
||||
async function getCountries() {
|
||||
const { data } = await supabase.from("countries").select();
|
||||
setCountries(data);
|
||||
}
|
||||
|
||||
function App() {
|
||||
const [countries, setCountries] = createSignal();
|
||||
|
||||
createEffect(() => {
|
||||
getCountries();
|
||||
});
|
||||
|
||||
async function getCountries() {
|
||||
const { data } = await supabase.from("countries").select();
|
||||
setCountries(data);
|
||||
}
|
||||
const [countries] = createResource(getCountries);
|
||||
|
||||
return (
|
||||
<ul>
|
||||
|
||||
Reference in new issue
Block a user