Alright, awesome! If you did the previous tasks you now know about reactivity.
Next we will look at the 'computed' property. It's a property that updates automatically when a dependency changes. That is different to methods as they are called when something happens as in event handling for example. Computed properties are written like methods but don't accept input arguments. They depend on other properties and are used to output something that depends on something else.
Much text but very simple - trust.
Use computed()
to compute changes on number
so that every time number
changes, the squared
variable is automatically updated.
📝 Note: Check out the on-click below! We do not use a function but inline JavaScript for incrementing!