Composition API FAQ
What is Composition API?
It is an umbrella term that covers the following APIs
- Reactivity API, e.g.
ref()
andreactive()
- Lifecycle Hooks, e.g.
onMounted()
andonUnmounted()
- Dependency Injection, i.e.
provide()
andinject()
Why Composition API?
Better Logic Reuse
The primary advantage of Composition API is that it enables clean, efficient logic reuse in the form of Composable functions.
More Flexible Code Organization
code related to the same logical concern can now be grouped together
Better Type Inference
Composition API utilizes mostly plain variables and functions, which are naturally type friendly