Deep comparison in PureComponent question
Chưa có ai nhận issue này.
- 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ả
Hello team,
We have a base class for React components that we're beginning to use. It's like PureComponent but does deep comparison of JSON-like values (just objects, arrays, and primitives). The purpose is to avoid re-renders when inputs haven't changed, even when objects/arrays were reconstructed.
import React from 'react';
import { compareObj } from './deepCompare';
export default class PureDeepComponent extends React.Component {
shouldComponentUpdate(newProps, newState) {
return !(compareObj(this.props, newProps) && compareObj(this.state, newState));
}
}
I was surprised that something like this wasn't included in React, and I'm wondering what the team's thoughts are -- was there a good reason for not doing something like this?
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.
Hướng nghiên cứu
Không có file, test hoặc entry point nào được xác định. Hãy bắt đầu bằng cách xem xét hành vi của PureComponent và shouldComponentUpdate được mô tả trong issue, sau đó xác định liệu kết quả mong muốn là một tính năng của React API hay là tài liệu; issue chưa hoàn tất cho đến khi phạm vi đó và các tiêu chí nghiệm thu được thống nhất.
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
- frontend
- Loại issue
- Tính năng
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- 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
- 18/100