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!