gitmyhub

react-state-problem

JavaScript ★ 4 updated 9y ago ⑂ fork

just a repo to show an example

A small React quiz app demo built to reproduce and study a state bug where old answer highlights stick around after retaking the quiz.

ReactJavaScriptCreate React Appsetup: easycomplexity 1/5

This is a small demo project created to illustrate a bug in a quiz application built with React. The real-world problem: when you take a quiz, answer some questions, see your results, and then click "try again" to retake it, the app sometimes doesn't fully reset. Specifically, the answer choices you selected in the previous attempt stay highlighted on screen even though you're starting fresh. It's a confusing user experience—you'll see old answer highlights mixed in with your new responses.

The author created this repo to work through the issue publicly, suspecting they have some mistaken mental models about how React manages state (the internal data that tracks things like "which answer did the user pick?"). The quiz flow is straightforward: you click on a topic called "materials," press start, answer questions randomly until you reach a results screen, then click "try again." If you repeat this cycle a few times, you'll occasionally see the bug where previous answers are still visually marked.

The project itself is a standard React application created with Create React App, a tool that sets up a working JavaScript project without needing to manually configure build tools. The README mostly contains the boilerplate documentation from Create React App—information about how to run it locally, deploy it, and manage dependencies. The actual application code isn't detailed in the README, so the focus is on reproducing the problem rather than explaining the solution.

This type of repo is useful for learning: it's a contained example of a real bug that a developer can study, debug, and use to understand how state management works in React applications. If you're interested in React and how to avoid these kinds of state-handling gotchas, this would be a good reference to explore.

Where it fits