Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding LocalStorage to persist state #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

chulinguy
Copy link
Owner

@chulinguy chulinguy commented Aug 31, 2023

Why was this change made?

We need to be able to favorite a dance move and have that persist if the page is reloaded.

What was the previous state

Previously, state was stored in memory so if you reloaded the page, it didn't save any changes. In this case, if you clicked the favorite button, it would be reset to unselected on a reload.

What is the current state

We added LocalStorage as a middleware to the redux Store and set up a listener so that if state changes, it will persist it in LocalStorage. Hence, if you favorite a move and reload the page, you will see that the move is still favorited.

Test Plan

  1. Select a move
  2. Click on the favorite button (heart)
  3. Reload the page. You should see the heart still selected.
  4. Click on the favorite button again to unfavorite it.
  5. Reload the page. You should see the heart is still unselected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant