Icon instance type not being respected

Đang mở
#314 0 bình luận 0 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
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
react, typescript
Lĩnh vực
developer-experience

Hướng nghiên cứu

Start by tracing how figma.instance<React.FunctionComponent> is rendered in the Code Connect preview, then compare it with the handling of icon instances passed as props. The issue does not name source files or tests, so locate the relevant preview and instance handling first. Done means the nested icon is shown as {ArrowRightMedium} instead of <ArrowRightMedium />.

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

Mô tả

API question

Hello,

I've setup my icon's example code to be react components. In the majority of my connections when icon's are being used in a prop it shows correctly as a react component but when its a child of a component it shows as a JSX element. I need it to always show as a react component not jsx.

Icon:

figma.connect(
    'https://www.figma.com/design/OMITTED/%E2%9D%96-00-Assets?node-id=OMITTED',
    {
        variant: {
            size: 'medium-24px',
            direction: '← left',
        },
        example: () => ArrowLeftMedium,
    }
);

Component connection:

figma.connect(
    IconButton,
    'https://www.figma.com/design/OMITTED/%E2%9D%96-02-Elements?node-id=OMITTED,
    {
        props: {
            ...other code,
            children: figma.nestedProps('icon-label-icon', {
                IconPrefix: figma.boolean('show-icon-L', {
                    true: figma.instance<React.FunctionComponent>('icon-left'),
                    false: undefined,
                }),
                IconSuffix: figma.boolean('show-icon-R', {
                    true: figma.instance<React.FunctionComponent>('icon-right'),
                    false: undefined,
                }),
            }),
        },
        example: ({ children, ...props }) => (
            <IconButton {...props}>
                {children.IconPrefix}
                {children.IconSuffix}
            </IconButton>
        ),
    }
);

In the code connect preview window:

Image

What I would like to be shown based on this example is the icon as {ArrowRightMedium} not <ArrowRightMedium />

Could I be directed on how to correct this? Thank you

Ngôn ngữ chính
TypeScript
Star
1.6k
Fork
126
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

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 figma/code-connect

Tất cả issue của figma/code-connect

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.