Skip to main content
Joaquin_H_Zubiri
November 20, 2024
Question

Getting an error when trying to access componentPropertyDefinition of a main component

  • November 20, 2024
  • 2 replies
  • 278 views

I’m getting the following error when trying to access propertyDefinitions of a main component.

I’m accessing this main component from an instance node by getMainComponentAsync, awaiting its promise.

In the documentation it says that componentPropertyDefinitions property is available for ComponentNode and ComponentSetNode.

But when I try to access it I get the following error:

in get_componentPropertyDefinitions: Can only get component property definitions of a component set or non-variant component

Isn’t a MainComponent a non-variant component?
If not, how do I access either a ComponentSet from an InstanceNode or its non-variant component version? I just need to check for variant options of a property to catch errors when matching it against data provided by the user…

This topic has been closed for replies.

2 replies

tank666
November 20, 2024

The mainComponent is a reference to ComponentNode. Also note:

That is, a Variant is also a ComponentNode.

Just check the parent of the main component.

And use the async method you mentioned instead of the deprecated mainComponent property from that example.

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
Joaquin_H_Zubiri
November 22, 2024

This worked! Thank you so much