Skip to main content
Tomas_Bana
March 19, 2024
Question

How to replace local component to component from library

Hello folks,
I need to replace all component instances on my page to components from library. I try using the function swapComponent but I don’t know if it is the right path. Here is my code:

const old_com = figma.root.findOne(node => node.type == "INSTANCE" && node.name == "Icon") as InstanceNode; 
let new_com = await figma.importComponentByKeyAsync("7c5dd1fbdbd83b87ac6d7XXX");

old_com.swapComponent(new_com)

Nothing happens after starting my code.

Thanks

This topic has been closed for replies.

1 reply

tank666
March 19, 2024
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