Setting Component Variable using JS

Hey Hey :wave:,

As the title says, it is possible to change the value of a component variable using JS?
I am currently trying to change a value and keep getting the error ‘Invalid left-hand side in assignment’

Example JS I am trying:

Thanks!

1 Like

Thanks - although this is the error it doesn’t make sense what is causing it, as using the exact same code in the example on a non-component variable works fine.

Obviously this relates to how component variables are operating behind the scenes, just not sure if there is a workaround.

1 Like

it works only when the chain returns a variable, but when it returns undefined you get the error. you have indeed the problem of not finding the variable, that is related to components, but the code is prone to errors and refactoring as the example of the link will make it more robust.

this may be helpful:

1 Like

Perfect! Thank you.
The method @aurelie gave in the thread did the job.

For anyone who may have this in the future, changing the example code to the following resolved the issue:

2 Likes

Glad you find the solution :slight_smile:
Using component local features is still undocumented as it is pretty new (for direct call in js)
We will try to update the doc as soon as possible :slight_smile:

2 Likes