HOC as a function won't get generated docs

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

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

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
javascript, react
Lĩnh vực
documentation, tooling

Hướng nghiên cứu

Bắt đầu bằng cách tái hiện ví dụ HOC trong issue và theo dõi cách parser xử lý class của component bên trong. Xác nhận hành vi docgenInfo mong đợi và bổ sung coverage cho thấy prop bổ sung của HOC được nhận diện; báo cáo không nêu file hoặc test hiện có nào.

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

Mô tả

Similar to #177 but a slightly different scenario...

Given a HOC method like so:

import { bool } from 'prop-types';

const withSomeExtraProps = Wrapped => {
  class HigherOrderComponent extends Component  {
    static propTypes = Object.assign({}, Wrapped.propTypes, {
      /**
       * This should be picked up in the docgenInfo
       */
      anExtraProp: bool,
    });
    static defaultProps = Object.assign({}, Wrapped.defaultProps, {
      anExtraProp: false,
    });
    // ....the rest of the HOC logic
  }
  return HigherOrderComponent;
}

export default withSomeExtraProps;

I understand that this wouldn't automatically mean that the export default withSomeExtraProps(Wrapped) wouldn't automatically get the docgenInfo from the HOC added, but I thought individually this HOC would have it's own docgenInfo that I could reference on it's own.

However, it seems the inner component class here doesn't get recognised and parsed. Does the component class need to be exported for the parser to find it?

Ngôn ngữ chính
TypeScript
Star
3.8k
Fork
316
Merge trung bình
3 giờ 28 phút
Pull request đã merge (30 ngày)
6

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.

Issue khác của reactjs/react-docgen

Tất cả issue của reactjs/react-docgen

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.