callstack / callstack/react-native-pager-view

useMemo inside useState in example

Đang mở
#976 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
question
Ngôn ngữ chính
TypeScript
Star
3.4k
Fork
476
Merge trung bình
10 ngày 21 giờ
Pull request đã merge (30 ngày)
2

Mô tả

## Ask your Question

There's a `useNavigationPanel` hook in the hook folder of the example project. I was trying to get deep in how to use the react-native-pager-view and I saw this [useMemo](https://github.com/callstack/react-native-pager-view/blob/2afcbf9bcfbfad0bee90c66c344f5cfebcf9836a/example/src/hook/useNavigationPanel.ts#L28) as the **initializer of useState.**
Is it a mistake? What kind of syntax is it and what is the reason?
As far as I know, the `useState` initializer executes just once before the first render and will not execute again unless the component remounts.
So if it's on purpose, then please explain it. Otherwise, I can create a PR and change it to a normal `useState`

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Start with example/src/hook/useNavigationPanel.ts and inspect the useMemo call linked in the issue as the useState initializer. Compare that initializer with the surrounding hook usage and the example’s expected behavior. Done means the initializer’s intent is established and the example either retains it with an explanation or uses the simpler form requested.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
react-native, typescript
Lĩnh vực
mobile
Loại issue
Tái cấu trúc
Độ khó
1/5
Thời gian dự kiến
1-3 giờ
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
48/100

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.