Pinned subjects: a bad localStorage value crashes the page
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- react, typescript
- Lĩnh vực
- frontend
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- TypeScript
- Star
- 22
- Fork
- 66
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của CodeChefVIT/papers-codechef
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
CodeChefVIT/papers-codechef#552 ·
-
/api/upcoming-papers Throws 404 When No Exams are ActiveCó thể đã có người làm @Dx-Alz-xD đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
CodeChefVIT/papers-codechef#549 · 1 reaction ·
-
Hardcoded "BMAT102L" Default Course CodeCó thể đã có người làm @Dx-Alz-xD đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
CodeChefVIT/papers-codechef#548 ·
-
Search Bar NaN Sorting & Console Log SpamCó thể đã có người làm @Dx-Alz-xD đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
CodeChefVIT/papers-codechef#547 ·
-
Local dev: upload, request and subscribe return 500 when Upstash isn't configuredCó thể đã có người làm @Dx-Alz-xD đã nhận hôm nay. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 25/100
CodeChefVIT/papers-codechef#558 ·
Tất cả issue của CodeChefVIT/papers-codechef
Issue tương tự
-
Language request: NixĐang mởenhancement language
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
pngwn/twinkleplop#178 ·
-
Type: Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
resend/react-email#3889 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
build P3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
maniator/verticopolis#1945 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Admin users page number stays stale after filteringCó thể đã có người làm @matthewxkong đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
feature request needs triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100