Skip to content

Instantly share code, notes, and snippets.

@claeusdev
Last active June 14, 2023 23:34
Show Gist options
  • Save claeusdev/ffd80924888730b9af9f941ee1482865 to your computer and use it in GitHub Desktop.
Save claeusdev/ffd80924888730b9af9f941ee1482865 to your computer and use it in GitHub Desktop.
Assignment for better javascript/Typescript/React.

Assignment 1

We want to get/have access to all values stored in browser storage. Implement (complete) the hook below such that it meets the acceptance criteria. We want to have the ability to read, add and update values from the browser storage when the hook is called. Think about all the CRUD actions for each object returned from the useBrowserStorage() hook.

IMPLEMENATION NOTES

  1. for. v1 can be as poor as possible because we shall review and work on refactoring
  2. v2 consider better state management ( context, stateHooks, reducers )
  3. v3 consider performance improvements ( caching, memoizing etc.)
const useBrowserStorage = () => {
// .....CODE TO Support the return values ... //

// each of these should have setter and getter methods
// setter sets new/updated information
// get gets saved information

 return {
    localStorage: {},
    sessionStorage: {},
    cookies: {}
  }
}

Acceptance Criteria

const { localStorage, sessionStorage, cookies } = useBrowserStorage();
localStorage.get("KEY");
localStorage.set("key", "newValue")

const localStore = localStorage.get("KEY")

//..... same for sessions and cookies ....

SUBMISSION

  1. Create a new repo and add me as a collaborator
  2. For every object returned from the hook, create a branch (conventional commits)[https://www.conventionalcommits.org/en/v1.0.0/]
  3. Open a PR for each branch and add me (@claeusdev) to the reviewers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment