feat: Abstract LocalStorage Usage in Indicator.tsx
#125
Labels
enhancement
New feature or request
good first issue
Good for newcomers in the OSP Community.
up for grabs
issues that are open for contributors
Description
Currently, the
Indicator.tsx
component directly accesseslocalStorage
to retrieve and manage the OS version. This approach can lead to code that is harder to test and maintain. To improve the codebase, we should abstract thelocalStorage
interactions into a custom hook.Proposed Solution
Create a custom hook,
useOsVersion
, to encapsulate the logic for accessing and updating the OS version fromlocalStorage
. This hook will manage the state and side effects related tolocalStorage
, making theIndicator.tsx
component cleaner and more focused on its primary responsibilities.Benefits
Indicator.tsx
component will be more focused and easier to understand.localStorage
will be isolated, making it easier to write unit tests.useOsVersion
hook can be reused in other components if needed.Additional Notes
localStorage
being unavailable in certain environments (e.g., server-side rendering).localStorage
, such as quota exceeded errors or JSON parsing errors.By abstracting the
localStorage
usage into a custom hook, we can enhance the maintainability and scalability of our codebase. This approach also promotes the separation of concerns, making each component and hook responsible for a single aspect of the application's functionality.The text was updated successfully, but these errors were encountered: