Bug Report
Building: School House
Difficulty (your estimate): Easy
What is broken?
In the practice section, selecting a new category tab displays questions from the previously selected category instead of the newly selected one.
Steps to reproduce
- Go to the School House (Practice section).
- Click on any category tab (e.g., Category A).
- Click on a different category tab (e.g., Category B).
- Observe that the questions displayed belong to Category A, not Category B.
Expected behavior
The question list should immediately update to fetch and display questions from the currently clicked category.
Actual behavior
The UI renders questions from the previously viewed category. No console errors are thrown; it is a logical state bug that trails one step behind the user's clicks.
Root cause
React state updates are queued and do not process immediately. The original code used the current, soon-to-be-stale state variable (activeCategory) to update the question category. Because the component hadn't re-rendered yet, it passed the old category value into the question fetcher.
Fix
Updated the function to bypass the stale state and pass the incoming argument directly.
Changed setQuestionCategory(activeCategory) to setQuestionCategory(nextCategory).
Bug Report
Building: School House
Difficulty (your estimate): Easy
What is broken?
In the practice section, selecting a new category tab displays questions from the previously selected category instead of the newly selected one.
Steps to reproduce
Expected behavior
The question list should immediately update to fetch and display questions from the currently clicked category.
Actual behavior
The UI renders questions from the previously viewed category. No console errors are thrown; it is a logical state bug that trails one step behind the user's clicks.
Root cause
React state updates are queued and do not process immediately. The original code used the current, soon-to-be-stale state variable (
activeCategory) to update the question category. Because the component hadn't re-rendered yet, it passed the old category value into the question fetcher.Fix
Updated the function to bypass the stale state and pass the incoming argument directly.
Changed
setQuestionCategory(activeCategory)tosetQuestionCategory(nextCategory).