Use light-weight functional components if you want stateless components.
Components consist of many different parts in Vue -
- computed properties
Data property in particular stores states of the component, and enables the component to react to prop changes by keeping track of all that the component has to go through.
What if you want no states? For e.g. you have a ‘Contact Service’ component that is statically displayed as an icon on the main page, or a footer component that takes in a prop and displays its value.
In these cases, you can create a lighter version of the regular Vue component that is fast and joyful. This is called “functional components” in Vue.
You create the functional component like so -
A functional component has “functional” tagged against template and has -
- access to event props and
- no access to states and no ways of storing values by itself - no stores, no router and no window object