Conversation
…d shared axios instance - Added shared api.js module - Introduced VITE_API_BASE_URL via .env - Removed hardcoded backend URLs across components Fixes c2siorg#83
- Replaced static placeholder data - Integrated API call - Added loading and error states - Render raw GDB output safely
|
|
||
| useEffect(() => { | ||
| fetchThreadsData(); | ||
| }, [refresh]); |
There was a problem hiding this comment.
Since this component performs async requests inside useEffect, we should consider adding cleanup using AbortController to prevent state updates on unmounted components and avoid race conditions when refresh changes rapidly.
| fetchThreadsData(); | ||
| }, [refresh]); | ||
|
|
||
| const hasThreads = threads && !threads.toLowerCase().includes("no threads"); |
There was a problem hiding this comment.
While threads && ... protects against null or undefined, it doesn't protect against Type Errors. If the backend ever returns a non-string value (e.g., a number, a boolean, or an object), the application will throw a TypeError because .toLowerCase() does not exist on those types.
I suggest something along the following lines:
const hasThreads =
typeof threads === "string" &&
threads.trim().length > 0 &&
!threads.toLowerCase().includes("no threads");
Good catches both — updated with AbortController cleanup and typeof guard. |
Replaced the static placeholder data in the Threads component with real data from the /threads backend endpoint.
Previously, the component rendered hardcoded mock thread objects. This PR integrates the centralized api module to fetch actual GDB thread output from the server and render it safely.
Changes made:
Removed hardcoded thread array
Added API call to /threads
Added loading and error states
Rendered raw GDB output inside a
Added safe handling for empty / "No threads" responses
Ensured no React warnings or console errors