Skip to main content
Question

There seems to be a problem with JSX compilation

  • August 5, 2023
  • 1 reply
  • 259 views

Helium2

In this example, List will get different props.children value. And here are my codes:

const { AutoLayout, Text } = figma.widget;

function List(props: any) {
  console.log('List children length', props.children.length, props.children);
  return <AutoLayout name={props.name}>{props.children}</AutoLayout>;
}

export function MenuUsage() {
  return (
    <AutoLayout>
      <List>
        {[1, 2].map((number) => (
          <Text key={number}>{`${number}`}</Text>
        ))}
      </List>
      <List
        children={[3, 4].map((number) => (
          <Text key={number}>{`${number}`}</Text>
        ))}
      ></List>
    </AutoLayout>
  );
}

1 reply

Helium2
  • Author
  • 1 reply
  • August 5, 2023

I hope that props.children can get a one-dimensional array, no matter how the array in children is passed in.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings