Spaces:
Running
Running
Create App.tsx
Browse files
App.tsx
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
import { useState, useEffect } from 'react'
|
3 |
+
import { supabase } from '../utils/supabase'
|
4 |
+
|
5 |
+
function Page() {
|
6 |
+
const [todos, setTodos] = useState([])
|
7 |
+
|
8 |
+
useEffect(() => {
|
9 |
+
function getTodos() {
|
10 |
+
const { data: todos } = await supabase.from('todos').select()
|
11 |
+
|
12 |
+
if (todos.length > 1) {
|
13 |
+
setTodos(todos)
|
14 |
+
}
|
15 |
+
}
|
16 |
+
|
17 |
+
getTodos()
|
18 |
+
}, [])
|
19 |
+
|
20 |
+
return (
|
21 |
+
<div>
|
22 |
+
{todos.map((todo) => (
|
23 |
+
<li key={todo}>{todo}</li>
|
24 |
+
))}
|
25 |
+
</div>
|
26 |
+
)
|
27 |
+
}
|
28 |
+
export default Page
|