diff --git a/pruebas/01-reading-list/anthonyeca/src/App.jsx b/pruebas/01-reading-list/anthonyeca/src/App.jsx index 766184013..6648ddfb4 100644 --- a/pruebas/01-reading-list/anthonyeca/src/App.jsx +++ b/pruebas/01-reading-list/anthonyeca/src/App.jsx @@ -1,5 +1,5 @@ import './App.css' -import { useState } from 'react' +import { useEffect, useState } from 'react' import { Book } from './components/Book' import { BookContainer } from './components/BookContainer' import data from '../../books.json' @@ -8,11 +8,21 @@ import { Category } from './components/Category' import { Footer } from './components/Footer' function App() { - const [library, setLibrary] = useState(data.library) + const library = data.library const [lecture, setLecture] = useState([]) const [filtered, setFiltered] = useState([]) const [activeGenre, setActiveGenre] = useState('') + if (activeGenre !== '') { + localStorage.setItem('category', activeGenre) + } + useEffect(() => { + const localStorageCategory = localStorage.getItem('category') + if (localStorageCategory && localStorageCategory?.length > 1) { + setActiveGenre(localStorageCategory) + } + }, []) + return ( <> { GitHub Portafolio