-
-
Notifications
You must be signed in to change notification settings - Fork 428
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Bug Description
π Problem
The Output component had multiple issues related to stability, state handling, and React best practices, which could lead to crashes or inconsistent behavior.
β οΈ Issues Identified
- Potential Crash (High Priority)
- Accessing
qaPairsFromStorage["output"]without checking existence could cause runtime crashes
- Incorrect Default State
questionTypecould benullif not found in localStorage, leading to unexpected behavior
- Memory Leak Risk
- Web Worker was not safely cleaned up in all scenarios
- Direct DOM Manipulation
- Dropdown was handled using direct DOM methods instead of React state
- Unsafe localStorage Parsing
- Default structure from localStorage could lead to type mismatch issues
β Fix Implemented
- Added safety checks before accessing
qaPairsFromStorage["output"] - Provided fallback value for
questionType - Ensured proper cleanup of Web Worker
- Refactored dropdown logic using
useStateanduseRef - Improved handling of parsed localStorage data
π‘ Benefits
- Prevents runtime crashes
- Improves application stability
- Aligns with React best practices
- Safer and more predictable state handling
- Cleaner and more maintainable code
π Affected File
eduaid_web/src/pages/Output.jsx
Steps to Reproduce
No response
Logs and Screenshots
No response
Environment Details
No response
Impact
Critical - Application is unusable
Code of Conduct
- I have joined the Discord server and will post updates there
- I have searched existing issues to avoid duplicates
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working