DEV Community

Discussion on: 5 things I struggled with when learning React with a Vue background

Collapse
 
jeremyling profile image
Jeremy

Tbh, I haven't had the opportunity to work with the Composition API. Correct me if I'm wrong, from what I understand the Composition API does not remove the Options API functionality. It is an additive feature that helps developers to break up complex components into reusable hooks (as you say very similar to React hooks). If so, the glossary above is still relevant, the only difference being that each map maps to both the Vue option and the equivalent API within Vue composables.

I personally am a fan of React hooks. I write quite a few custom hooks of my own and if Vue composables are as flexible as React hooks, and I'm sure they can be written to be as flexible, then I'd definitely be using composables where appropriate.

Haven't tried Svelte out yet but just going through the getting started guide, it looks like a framework that's even closer to vanilla HTML/CSS/JS than Vue is. Will definitely spend some time on it when I can!

Collapse
 
seangwright profile image
Sean G. Wright

Correct, you can use both the Options API and the Composition APIs in the same app.

There is a community library that brings together many common composables for easy re-use. Having used it in a couple apps, I can say it's wonderful and really proves out the way they've been designed for Vue 3.

vueuse.org/functions.html

Here's some examples of the <script setup> syntax, which I've also adopted and found to be great for removing boilerplate.

v3.vuejs.org/api/sfc-script-setup....