Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Doesn't find HOCs that just wrap & re-export component

Đang mở
#177 10 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ó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
45/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

Hướng nghiên cứu

Bắt đầu với các ví dụ hello-button.js và button.js, sau đó lần theo resolver findAllComponentDefinitions để xem tại sao một component được import và bọc bởi connect lại bị bỏ sót. Xác nhận thay đổi bằng cách kiểm tra rằng HelloButton được nhận diện là một component, trong khi Button vẫn được phân tích cú pháp chính xác.

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

Mô tả

needs-discussion

Some HOCs aren't correctly parsed when they're just calling a function on an imported component. For example, exporting a HelloButton component that just exports an imported Button component wrapped in redux connect:

hello-button.js:

// @flow
import { connect } from 'react-redux';

import { sayHello } from '../actions/hello';
import Button from '../components/Button';

const mapStateToProps = () => ({
        label: 'Say something',
});

const mapDispatchToProps = dispatch => ({
        handleClick: () => {
                dispatch(sayHello('Hi!!!'));
        },
});

// HelloButton
export default connect(mapStateToProps, mapDispatchToProps)(Button);

button.js:

// @flow
import React from 'react';
import './index.css';

type Props = {
        label: string,
        handleClick: Function
};

const Button = ({ label, handleClick }: Props) =>
        <button styleName='button' onClick={handleClick}>{label}</button>
;

export default Button;

Button is properly parsed, but HelloButton is not considered a component, even when using the findAllComponentDefinitions resolver.

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.