How to I update a variable in JS Object?

As they are called “variables”, I assume you can change their value.
I’ve tried the following, non seems to work.

export default {
	myVar1: 1,
	increase: () => {
		myVar1++; // NOT WORKING
		this.myVar1++; // NOT WORKING
	}
}

Hi there!
This issue is related to the mutation of JSObject variables- [Feature]: Allow mutation of JS object variables · Issue #18088 · appsmithorg/appsmith · GitHub
we are currently working on supporting this functionality. ETA: end of this month.

Can I suggest you use the appsmith store for right now pending the time this would be fixed? Let me know if this suggestion works for your use case.

1 Like