Knowledgebase

Reactivity and State in Vue Print

  • frontenddevelopment, frontend, guide, howto, solution, zillionkinghost, hosting, support
  • 0

Data that updates the interface.

WHAT REACTIVE STATE IS

Values tracked by the framework, updating the interface when changed.

WHAT THE TWO PRIMITIVES ARE

One wrapping a single value One making an object reactive

WHAT TO BE CAREFUL WITH

Accessing the wrapped value, which requires a property in code but not in templates Losing reactivity by destructuring a reactive object

WHY THAT SECOND POINT

Extracted values are plain copies, disconnected from the source.

WHAT TO DO ABOUT IT

Use the provided helper preserving the connection.

WHAT COMPUTED VALUES ARE

Values derived from state, recalculated only when their dependencies change.

WHAT TO USE THEM FOR

Anything derived.

WHY

It prevents storing derived values in state, where they diverge.

WHAT WATCHERS ARE FOR

Reacting to a change with a side effect.

WHAT THEY ARE NOT FOR

Computing derived values.

WHAT TO PREFER

Computed values, wherever the result is simply derived.

WHAT TO KEEP MINIMAL

State, as in any framework.


Was this answer helpful?
Back

Are you happy with your experience? Leave us a review on Trustpilot.


Trustpilot