Sorry for my dumb questions, but i don’t know what you mean “variable already stores a ComponentNode”. Maybe I asked the wrong question.
Now I have an instance, but when I try set the property I get a error
let importComponent = await Figma.importComponentByKeyAsync(“5cad03bxxxxx”);
importComponent.createInstance()
importComponent.setProperties({‘Layout’: ‘Mobile’});
Error: Property ‘setProperties’ does not exist on type ‘ComponentNode’.
I don’t need to change only properties. My component includes a more component and Ii need access to all children’s components. And don’t know how 😦
How i get access to the component (name = favorite) which is inside the “ImportComponent” ??
figma.com
Find the desired node in the children’s tree.
Thanks for your advice. I use the function children, and get back the children instance component. But when i trying to change property with .setProperties. But I’m getting an error does not exist on type ‘SceneNode’.
We are a bit confused, I don’t know how to change the text or property for embedded component instances {label} or instance favorite. Attached is an example of the structure of a component
Thanks
On which node was the setProperties
method called?
Call the setProperties
method on the “Participant” instance or change the characters
property value of the “{Label}” text node.
// Set a value for a component's text property
pacticipantInstance.setProperties({'textPropertyName#id': 'Something'});
// Or change the value of the characters property
label.characters = 'Something';
Call the above method on the “Favourite” instance.
On which node was the setProperties
method called?
this is my code:
let importComponent = await figma.importComponentByKeyAsync("5cad03b3xxx");
importComponent.createInstance()
importComponent.children[0].setProperties({'State': 'Like'})
I don’t know why you use this way, but I would do it like this:
let importComponent = await figma.importComponentByKeyAsync(key);
let instance = importComponent.createInstance();
instance.childrene0].setProperties(obj);
Also make sure that childrene0]
is an instance.
And where do you see the error: in the Figma app console or in the IDE?
My mistake, I see the error in my IDE. But when I run the plugin in Figma it works.
Thanks.
I have a last thing. When I am using setProperities and choosing from options everything is good. But I don’t no how a set value for properties (set text).
My code:
instance.childrene1].childrene0].setProperties({‘Time’: ‘11:00’});
I want a set text for properties Time, but my code doesn’t work.
Thx.