[x] create a new directory within src called hooks
[x] within hooks, create a file called useLocalStorage.ts
[x] create the hook (reference back to module 3 coursework)
[x] this file should export a minimum of 2 things localStorageKeys and useLocalStorage
[x] now that the directory and the file have been created, add the new path to our complier path aliases list such that we can have pretty imports (i.e. components/Target vs ../../components/Target)
// localStorageKeys will be a key:value object that contains the localStorage keys such that they can be referenced from other files
const localStorageKeys = {
keyIWantToUse: 'this is the key'
}
// ----
// otherFile.ts
// other files can then reference this object like:
...
useLocalStorage(localStorageKeys['keyIWantToUse']);
hooks
useLocalStorage.ts
localStorageKeys
anduseLocalStorage
components/Target
vs../../components/Target
)