Pinned subjects: a bad localStorage value crashes the page

Đang mở
#559 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

@Dx-Alz-xD đang làm issue này rồi.

Từ ngày 11/11/2026.

  • #566 của @Dx-Alz-xD — đang mở

Đá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

  1. In the browser console put localStorage.setItem("userSubjects", "oops")
  2. Reload a page that shows pinned subjects
  3. 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

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của CodeChefVIT/papers-codechef

Tất cả issue của CodeChefVIT/papers-codechef

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.