reactjs / reactjs/react.dev

We have hooks, then still do we use Container components and Presentational components?

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

Chưa có ai nhận issue này.

discussion
Ngôn ngữ chính
JavaScript
Star
11.8k
Fork
7.9k
Merge trung bình
1 ngày 11 giờ
Pull request đã merge (30 ngày)
11

Mô tả

I think it is a bit confusing and maybe a doc or writing can explain the situation.

After we have hooks, do we still design our app into Container components and Presentational components? (Does it mean we should not divide up our app design into containers and presentational components?)

Or does it simply mean: in the past we use class components as containers with states, and function components as presentation components, and now we can use function components as both containers and presentational components, and the recommendation is still to divide our app design into containers and presentational component?

In the past, we can simply use class components ONLY and we could still divide our app design into containers and presentational components. So function component having state doesn't change that situation... the question is more like should we now still divide our app design into containers and presentational component? So nowadays we could still make container components using function components, and then, make presentational components and use function components to do that, and strictly do not use any hooks in them, because then they become stateful and therefore not just "presentational".

I think the short version of the question is: even with function components able to use states, should we still divide up our app into components that have states, and components that strictly do not have states and like "pure function" to present data?

@gaearon

https://stackoverflow.com/questions/60593403/for-reactjs-how-is-the-change-from-using-container-components-and-presentation

In the past, in ReactJS, one way was to divide our components into Container components and Presentational components, and even Dan Abramov wrote a note about it not any more the case if we can use Hooks now.

How should it be done now — how does Hooks solve the problem?

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

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

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.

Hướng nghiên cứu

Đọc nội dung issue cùng với câu hỏi Stack Overflow được liên kết và ghi chú của Dan Abramov. Hoàn thành nghĩa là tạo ra một phần giải thích tập trung cho tài liệu React, trả lời liệu Hooks có thay đổi hướng dẫn về các component container/presentational hay không.

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

Đánh giá

Công nghệ
javascript, react
Lĩnh vực
documentation, frontend
Loại issue
Tài liệu
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
35/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.