Figma Support Forum

Wiring up reactions from plugin

I’m creating some component set nodes at runtime composed of components from some external (team) library; when I try to set
myComponentNode.reactions = reactions;

It still gave me “Can’t assign reactions because it’s a read only property.”

I must have been missing something…

Thanks,

API Doc: ComponentNode
Discussion back in July

You need to overwrite the entire array. More about editing properties here:

Yes, I did try to set the whole reactions array property.

Does it have anything to do with being a component set node that uses external components?

I don’t think it should have any effect.

1 Like

Thanks a lot for the trick!
I tried the same thing, for both a local and external component, but I got this instead:

figma_app.03a53ce71eac9dcafba105307c26f2a0.min.js.br:831 Uncaught Error: in set_reactions: Reaction at index 0 was invalid
at ComponentNode.set_reactions [as reactions] (figma_app.03a53ce71eac9dcafba105307c26f2a0.min.js.br:831)
at :1:43

Could you record a video?

Hi, @tank666

It turned out that I had the wrong destinations (that were not the children of the same component set node) for the reaction. Figma is smart enough to know which ones are valid destinations, although the error message appears to be confusing…

In my VS Code, it still says “TS2540: Cannot assign to ‘reactions’ because it is a read-only property” both in the editor and on build, but actually it does work in Figma designer!

Screen Shot 2021-11-12 at 12.03.45 PM|690x142

Thanks a lot for the help!