Open jiaruisong opened 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.
any update on this? interested
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
Attempted Solutions and Observations
localStorage
upon navigating away and then restore this index usingsetCurrentCard
upon returning.setCurrentCard
may not be affecting the flashcard rendering process or is not properly integrated with the component's state management.Request for Assistance
setCurrentCard
is intended to influence the rendering of flashcards directly, or if an alternative method is recommended for this purpose?