Skip to main content
Question

How to replace local component to component from library

  • March 19, 2024
  • 1 reply
  • 311 views

Tomas_Bana

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 comments

1 reply

tank666
  • 4867 replies
  • March 19, 2024

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