Skip to content

Commit

Permalink
LocalStorage
Browse files Browse the repository at this point in the history
  • Loading branch information
jutaga committed May 8, 2023
1 parent 4615116 commit e031f44
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export const App = () => {
const [paginaActual, setpaginaActual] = useState(1);
const [totalPaginas, setTotalPaginas] = useState(1);


useEffect(() => {

const consultarApi = async () => {
Expand All @@ -31,12 +30,26 @@ export const App = () => {
//Mover la pantalla hacia arriva
const jumbotron = document.querySelector('.jumbotron');
jumbotron?.scrollIntoView({ behavior: 'auto' })
}

localStorage.setItem('previousSearch', busqueda);

}
consultarApi();

}, [busqueda, paginaActual])

useEffect(() => {
const ultimaBusqueda = localStorage.getItem('previousSearch');

if (ultimaBusqueda) {
setBusqueda(ultimaBusqueda);
}


}, []);



const paginaAnterior = () => {
const nuevaPaginaActual = paginaActual - 1;

Expand Down

0 comments on commit e031f44

Please sign in to comment.