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

Functionality: Create a localStorage Hook that Adds, Updates, or Retrieves an item #43

Closed
8 tasks done
larkinds opened this issue Sep 11, 2023 · 0 comments
Closed
8 tasks done

Comments

@larkinds
Copy link
Owner

larkinds commented Sep 11, 2023

Overview:

When a customer is using the website, we want to make sure that their data is persisted in case they accidentally navigate away from the page. Data to be persisted includes the items in their cart, their login/login status & relevant account information

Action Items:

Hook:

  • The hook sets data passed to it into localStorage & returns the created key
  • The hook reads or creates the Context
  • The hook retrieves any piece of data from localStorage as requested
  • The hook updates any previously set value in localStorage when requested
  • The hook uses JSON.stringify() and JSON.parse() to convert data to & from a string (since localStorage only supports strings)
  • The hook follows the [Rules of Hooks], and follows the naming convention for hooks

Misc:

  • Personal data about the customer is stored securely
  • A naming convention for how data is set into localStorage has been created and documented

Resources:

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

3 participants