From 6be5ca583bc489781fde7b5176b19541d915ca48 Mon Sep 17 00:00:00 2001 From: Melissa Date: Wed, 24 Jun 2026 14:38:08 +0200 Subject: [PATCH] added like that continue even with reload but buggy --- react-project/src/App.jsx | 5 +++++ react-project/src/components/Carte.jsx | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/react-project/src/App.jsx b/react-project/src/App.jsx index 3ea985a..0a54e52 100644 --- a/react-project/src/App.jsx +++ b/react-project/src/App.jsx @@ -1,6 +1,7 @@ import Header from "./components/Header"; import Footer from "./components/Footer"; import Carte from "./components/Carte"; +import { useEffect } from "react"; import { useState } from "react"; import "./App.css"; @@ -37,6 +38,10 @@ function App() { j.titre.toLowerCase().includes(recherche.toLowerCase()), ); + useEffect(() => { + document.title = `${jeux.length} jeux Zelda`; + }, []); + return ( <>
diff --git a/react-project/src/components/Carte.jsx b/react-project/src/components/Carte.jsx index 5d29a82..b67beef 100644 --- a/react-project/src/components/Carte.jsx +++ b/react-project/src/components/Carte.jsx @@ -3,7 +3,12 @@ import Badge from "./Badge"; import { useState } from "react"; function Carte(props) { - const [likes, setLikes] = useState(0); + const [likes, setLikes] = useState( + () => Number(localStorage.getItem("likes-" + props.id)) || 0, + ); + useEffect(() => { + localStorage.setItem("likes-" + props.id, likes); + }, [likes]); useEffect(() => {}, [likes]); return (