Skip to main content
Question

Is that possible to get a component by key. The one that i am getting from InstanceSwapPreferredValue?

  • April 25, 2024
  • 2 replies
  • 170 views

helgastogova

Is it possible to retrieve ‘COMPONENT’ or ‘COMPONENT_SET’ nodes using a key from InstanceSwapPreferredValue?

declare type InstanceSwapPreferredValue = {
  type: 'COMPONENT' | 'COMPONENT_SET'
  key: string
}

I noticed the function importComponentByKeyAsync(key: string): Promise<ComponentNode>, but I believe it might not be the right approach for my goal.

I’d like to render a list of these components (their instances) if possible. It would be nice to have something fast-working.

Thank you in advance for your help!

This topic has been closed for replies.

2 replies

Gleb
  • Power Member
  • April 25, 2024

That’s the right approach.

You need to import them by key, then export as images.


helgastogova

Thank you, Gleb! I will try 🙂

Update:

You need to import them by key

Looks like that function importComponentByKeyAsync is designed for published library components. I would like to operate with unpublished components in my file.

then export as images

Also, I would like to render them as instances, not images.

Trying to find a way, but don’t see any for now.