Pinned subjects: a bad localStorage value crashes the page
評估
- 難度
- 2/5
- 預估耗時
- 1-3 小時
- 新手友好度
- 35/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 停滯
- 技術堆疊
- react, typescript
- 領域
- frontend
研究方向
Start with the listed reads in src/components/Searchbar/pinned-searchbar.tsx, src/components/CatalogueContent.tsx, src/components/PinnedPapersCarousel.tsx, and src/components/ui/PinnedModal.tsx, then check whether the project has a shared utility pattern. The issue calls for a helper that returns an empty list and clears the key when stored data is missing, invalid, or not an array of strings; done means all listed reads use it and the reproduction no longer crashes. An open linked pull request (#566) means this work is already under way.
由索引模型根據 Issue 內容生成。
描述
Describe the bug
several components read pinned subjects with JSON.parse(localStorage.getItem("userSubjects") ?? "[]") w/o a try or catch and assume the result is an array
- src/components/Searchbar/pinned-searchbar.tsx (lines 56, 97, 136 and 155)
- src/components/CatalogueContent.tsx (lines 97 and 139)
- src/components/PinnedPapersCarousel.tsx (lines 66 and119)
- src/components/ui/PinnedModal.tsx (lines 105 and 147)
If the stored value isntt valid JSON, or isnt an array JSON.parse throws or .length/.filter fails, and the component crashes bad
To Reproduce
- In the browser console put localStorage.setItem("userSubjects", "oops")
- Reload a page that shows pinned subjects
- The page errors instead of showing an empty pinned list
Expected behavior
A small shared helper that returns [] (and clears the key) when the value is missing invalid or not an array of strings used everywhere these components read userSubjects
- 主要語言
- TypeScript
- 星號
- 22
- 分支
- 66
- PR 合併指標
- 30 天內沒有已合併 PR
環境準備
- 提供 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
CodeChefVIT/papers-codechef 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 72/100
CodeChefVIT/papers-codechef#552 ·
-
/api/upcoming-papers Throws 404 When No Exams are Active可能已有人在做 @Dx-Alz-xD 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 68/100
CodeChefVIT/papers-codechef#549 · 1 個 reaction ·
-
Hardcoded "BMAT102L" Default Course Code可能已有人在做 @Dx-Alz-xD 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 68/100
CodeChefVIT/papers-codechef#548 ·
-
Search Bar NaN Sorting & Console Log Spam可能已有人在做 @Dx-Alz-xD 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 75/100
CodeChefVIT/papers-codechef#547 ·
-
Local dev: upload, request and subscribe return 500 when Upstash isn't configured可能已有人在做 @Dx-Alz-xD 今天認領。 未關閉
難度 3/5 1-2 天 新手友好度 25/100
CodeChefVIT/papers-codechef#558 ·
查看 CodeChefVIT/papers-codechef 的全部 Issue
相似的 Issue
-
enhancement language
難度 2/5 1-3 小時 新手友好度 67/100
pngwn/twinkleplop#178 ·
-
Type: Bug
難度 2/5 1-3 小時 新手友好度 78/100
resend/react-email#3889 ·
維護者通常 1 天內回覆
-
build P3
難度 2/5 1-3 小時 新手友好度 82/100
maniator/verticopolis#1945 ·
維護者通常 1 天內回覆
-
Admin users page number stays stale after filtering可能已有人在做 @matthewxkong 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
feature request needs triage
難度 2/5 1-3 小時 新手友好度 72/100