Created
February 20, 2023 20:44
-
-
Save nataliaconde/a5437c5a7d7e01754935f2bf0b815b19 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// pages/index.js | |
export default function Home() { | |
const storeTasks = useGlobalStore((state) => state.tasks); | |
const storeDeleteTask = useGlobalStore((state) => state.deleteTask); | |
const storeClearTasks = useGlobalStore((state) => state.clearTasks); | |
const storeMarkTaskAsDone = useGlobalStore((state) => state.markTaskAsDone); | |
const storeMarkTaskAsUndone = useGlobalStore((state) => state.markTaskAsUndone); | |
const [tasks, setTasks] = useState([]); | |
useEffect(() => { | |
setTasks(storeTasks); | |
}, [storeTasks]); | |
return ( | |
// ... | |
<Grid container spacing={2}> | |
{tasks.map((task) => ( | |
<Grid item xs={12} md={4} key={task.id}> | |
<Task | |
{...task} | |
markTaskAsDone={storeMarkTaskAsDone} | |
markTaskAsUndone={storeMarkTaskAsUndone} | |
deleteTask={storeDeleteTask} | |
/> | |
</Grid> | |
))} | |
</Grid> | |
// ... | |
); | |
} | |
// Your final file should look like this: | |
// https://github.com/duplxey/back4app-containers-nextjs/blob/master/pages/index.js |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment