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:
Freddie authored and GitHub committed 2023-04-20 09:33:49 +01:00
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>