Icon instance type not being respected

Open
#314 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
react, typescript

Research direction

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 />.

Written by the indexing model from the issue text.

Description

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

Dominant language
TypeScript
Stars
1.6k
Forks
126
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from figma/code-connect

All issues in figma/code-connect

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.