Figma access master components

392 views Asked by At

Is there a way to traverse through masterComponents without having an instance in the document first?

Also, will a component's UUID change when the component is updated, and will that UUID be the same across all consumers of that component?

1

There are 1 answers

2
thenoobinator On

Figured it out. Wrote a utility function for it

export function traverse(node: any) {
    if ("children" in node) {
        if (node.type !== "INSTANCE") {
            for (const child of node.children) {
                traverse(child)
                if (child.mainComponent) {
                    console.log(`name: ${child.mainComponent.name}`)
                    console.log(`key: ${child.mainComponent.key}`)
                }
            }
        }
    }
}