ABSanthosh / react-quizlet-flashcard

A simple quizlet-like flashcard component written with TypeScript
https://www.npmjs.com/package/react-quizlet-flashcard
MIT License
70 stars 7 forks source link

Issue with Persisting User Progress in Flashcard Array #13

Open jiaruisong opened 5 months ago

jiaruisong commented 5 months ago

Problem Summary

I am encountering a problem with maintaining the user's progress within a flashcard array component. The key functionality required is for the application to save the user's current position within the flashcard sequence locally on the client side. This way, if a user switches tabs or navigates away and then returns, they can continue from the last flashcard they viewed instead of starting over from the first flashcard. Attempts to use a setCurrentCard function to achieve this have been unsuccessful, leading me to believe that this function might not directly influence how the flashcard is rendered or does not interact with the component's state as expected.

Expected Behavior

When a user navigates away from the flashcard component (switching tabs, navigating to a different page, etc.) and then returns, their progress should be preserved, allowing them to resume from the last flashcard they were viewing.

Actual Behavior

Currently, despite attempts to implement functionality to save and restore the user's progress (using a setCurrentCard approach), the flashcard array resets to the first card whenever the user leaves and returns to the component, indicating a failure to persist user progress across sessions.

Steps to Reproduce

  1. Navigate to the flashcard component and interact with it to change the currently displayed flashcard from the default (first) position.
  2. Switch tabs or navigate away from the page.
  3. Return to the flashcard component and observe that the display has reset to the first flashcard, instead of displaying the last flashcard viewed.

Attempted Solutions and Observations

Request for Assistance

ABSanthosh commented 5 months ago

Hey! I forgot about this case and I didn’t notice it during development. Give me a few days, I’ll try to add that to the library.

In the meantime, if you want to come up with a solution, feel free to make a PR.

harbolaez commented 2 months ago

any update on this? interested