Skip to main content
Jun 22, 2023 3:38 PM UTC
Question

Object properties not carried over between code and ui

Here is my code:
code.js

...
const variableCollection = figma.variables.getLocalVariableCollections();
const variables = figma.variables.getLocalVariables();
...
showUI(
    {
      height: 137,
      width: 240,
    },
    { collections: variableCollection, vars: variables }
  );

ui.js

function Plugin(props: {
  collections: VariableCollection[];
  vars: Variable[];
}) {
...
const collectionComponents = props.collections.map((node) => {
    return <Text>{node.name}</Text>;
  });
...

For some reason, when I send the prop through, some keys gets removed. What is causing this?

Below is an image of how it looks like before and after
image

This topic has been closed for replies.

1 reply

tank666
Jun 22, 2023 9:35 PM UTC

As you can see, all property values, except for id, have not been evaluated and are displayed in the console as (…). Therefore, you need to create a copy of objects with already evaluated values, and only then send this copy to the UI. You can get these values by calling the getters of the required properties.

UX/UI designer. Figma expert. Creator and developer of plugins and widgets for Figma and FigJam. Check out my resources in Figma Community: figma.com/@tank