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

Save game progress between sessions #37

Open
0bubbles0 opened this issue Oct 29, 2021 · 0 comments
Open

Save game progress between sessions #37

0bubbles0 opened this issue Oct 29, 2021 · 0 comments

Comments

@0bubbles0
Copy link

This is how we did it:

  useEffect(() => {
    setBerry(JSON.parse(window.localStorage.getItem(`${props.user.id}`)));
  }, []);

  useEffect(() => {
    window.localStorage.setItem(`${props.user.id}${props.category}`, berry);
  }, [berry]);

Then it could save hangman progress for a certain user in local storage. You can check what is in local storage in Browser DevTools → Application → Local Storage (it's near where we can look at Cookies)

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

No branches or pull requests

1 participant