Skip to main content
Question

Cannot import a team library component in my plugin

  • August 24, 2023
  • 1 reply
  • 464 views

Hello, I have been trying to follow the Figma videos on creating my first plugin. However when we get to the point of logging the name of a team library component to the console I get the error: “cannot read property ‘children’ of null”.

The code works fine when I’m in the local file for that particular component, however once I go to another project file, I get the error. I have checked to make sure the team library is enabled in the assets panel, and I can easily import the component into the file through search or even through its ID in Automator.

I’m using the following code to try to log the component properties:

 const postComponentSet = figma.root.findOne(node => node.type == "COMPONENT_SET" && node.name == "card") as ComponentSetNode;

  console.log(postComponentSet);
  console.log(postComponentSet.children);
  console.log(postComponentSet.name);

I also tried importing by Key as well, and have tried this route:

async function importNode() {
    let importComponent = await figma.importComponentByKeyAsync(key);
    importComponent.createInstance()
}
importNode()

But for some reason it cannot find the component unless I’m in the file which the component is located.

Any advice is appreciated!

1 reply

Aaron_Nebbs

Did you get anywhere with this?

I am trying to do the same thing.


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