reactjs / reactjs/react-docgen
Support Object.assign in propTypes definition
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- TypeScript
- Star
- 3.8k
- Fork
- 316
- Merge trung bình
- 5 giờ 7 phút
- Pull request đã merge (30 ngày)
- 4
Mô tả
In my React App, I have components which pass receive properties but just pass them as is to their child component. The parent component sort of extends the child component properties, so I'm using Object.assign to avoid code duplication. Unfortunately, recat-docgen doesn't seem to handle propTypes values which are evaluated from a function.
For example, let's say I have a component named ParentComponent and a component named ChildComponent.
The render function of the ParentComponent looks like this:
render() {
return (
<ChildComponent childPropA="SomeValue" childPropB="AnotherValue" />
);
}
When I render the ParentComponent my code looks like this:
<ParentComponent parentPropA="Value" childPropA="SomeValue" childPropB="AnotherValue" />
Therefore, I use Object.assign for setting ParentComponent.propTypes:
ParentComponent.propTypes = Object.assign({}, ChildComponent.propTypes, {
parentPropA: React.PropTypes.string
});
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ó tệp nguồn hoặc test nào được nêu tên. Hãy bắt đầu bằng cách lần theo cách react-docgen đánh giá propTypes của component, sau đó tái hiện ví dụ Object.assign từ issue. Hoàn thành nghĩa là cả propTypes được kế thừa và propTypes được định nghĩa cục bộ đều được trích xuất chính xác, với một regression test bao quát ví dụ này.
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, tooling
- Loại issue
- Tính năng
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- 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
- 35/100