Skip to content

Save game progress between sessions #37

@0bubbles0

Description

@0bubbles0

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)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions