AOSSIE-Org / AOSSIE-Org/EduAid

Refactor: Extract quiz history storage logic into a custom hook (useQuizHistory)

Offen
#485 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
JavaScript
Sterne
171
Forks
425
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

### Description
Hey team! While looking through the `Text_Input.jsx` component, I noticed that the logic for handling `localStorage` (saving and retrieving quiz history) is written directly inside the UI component.

While it works perfectly fine right now, keeping this logic inside the component makes it a bit bulky and hard to reuse. If we ever want to access the user's quiz history from a different page or component in the future, we would have to duplicate that storage logic.

### Proposed Solution
I propose we extract the `localStorage` logic into a dedicated custom React hook, `useQuizHistory`.

This hook would handle all the underlying reading and writing to the browser's storage, and simply return the history state and an update function.

### Why this is beneficial
* **Separation of Concerns:** UI components should ideally just handle the UI. Moving data persistence to a hook keeps `Text_Input.jsx` much cleaner.
* **Reusability:** The new hook can be imported anywhere in the app if needed.
* **Maintainability:** If we ever change how we store this data in the future (e.g., moving from local storage to a backend database), we only have to update the logic in one single file (the hook), rather than hunting through UI components.

I'd love to work on this and submit a PR if the maintainers think this is a good structural improvement!

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.