Con solid-js es muy simple lo hice con un show
Introducci贸n a SolidJS
Los problemas que resuelve SolidJS
Instalaci贸n de SolidJS: usando un template para nuestra aplicaci贸n
Primitiva reactiva de SolidJS: signals
Primitiva reactiva de SolidJS: effect
Primitiva reactiva de SolidJS: memo
Quiz: Introducci贸n a SolidJS
Reactividad a profundidad
驴Qu茅 es la reactividad?
Crea tu propia libreria reactiva: MiniSolid
Signals aplicados a un proyecto
Effects aplicados a un proyecto
Crea mejores aplicaciones con signals derivados
Memos aplicados a un proyecto
Renderizado de un proyecto en SolidJS
Quiz: Reactividad a profundidad
Renderizado en Solid
ToDo App: usando reactividad y sistemas de renderizado en un proyecto
Implementando el Dark Mode a un proyecto
Renderizado Condicional
Renderizado de Listas
Manejo de Eventos
Quiz: Renderizado en Solid
Reactividad en Listas
Reactividad en Listas
Stores para optimizar renderizados
Como implementar Stores a un proyecto
Funci贸n Produce para usar sintaxis de Javascript
Quiz: Reactividad en Listas
Componentes
驴Qu茅 son componentes en SolidJS?
Usando Props para comunicaci贸n entre componentes de una aplicaci贸n
Manejando eventos en una aplicaci贸n SolidJS
Guarda el estado de una aplicaci贸n con LocalStorage
Deploy de la aplicaci贸n ToDo con Netlify
Comparte tu proyecto con la comunidad
Quiz: Componentes
You don't have access to this class
Keep learning! Join and start boosting your career
When developing a web application, maintaining state across user sessions is crucial to provide a consistent experience. Local Storage is a powerful tool that allows us to store data in the browser. This ensures that even if the user closes or refreshes the page, the changes persist. In the class we will discuss how we can implement local storage to enhance our application, ensuring that all modifications made by the user remain intact.
The use of effects in JavaScript is fundamental when we want to handle side effects, those changes that occur outside the reactivity and rendering system of our application. In this case, effects allow us to react automatically to changes in the application and update the local storage according to these changes. This is the strategy we will follow:
Create an effect:
createEffect
primitive to detect when there are changes in our task list (all).localStorage.setItem
inside the effect to store a copy of the list state in the local storage.createEffect((() => { localStorage.setItem('all', JSON.stringify(all));});
Change Observation:
To ensure that our application starts with the data that the user saved last time, we must initialize the state with the information from the local storage:
Retrieve data from Local Storage:
JSON.parse
to convert the data stored as a string into a usable JavaScript object.const allLocalStorage = JSON.parse(localStorage.getItem('all')) || [];
Store initialization:
todosLocalStorage
.Saving the dark mode preference is another important aspect, especially in terms of user experience. Let's see how to do it:
Accessing and saving the mode:
const darkMode = localStorage.getItem('darkMode') === 'true';
Implement the change effect:
body
class occurs in parallel with the change in storage.createEffect((() => { localStorage.setItem('darkMode', darkMode.toString());});
Example usage:
Finally, for those who wish to deepen their learning, an interesting challenge is presented: create an additional list to store only the items marked as completed. This exercise will challenge your logic and consolidate your understanding of topics covered in the course. The implementation of two lists invites us to use cycles and to differentiate derived signals, encourage you to try and continue learning while structuring your application in a more robust and dynamic way!
Contributions 1
Questions 0
Con solid-js es muy simple lo hice con un show
Want to see more contributions, questions and answers from the community?