Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I have a fairly large/complex SaaS platform built with Vue 3 composition API. Can maybe shed some light.

A while ago I wrote the same component in Vue 2 and Vue 3 as an example of one versus the other:

https://codesandbox.io/s/bold-shamir-uqm0b?file=/src/compone...

https://codesandbox.io/s/bold-shamir-uqm0b?file=/src/compone...

If you meant more from a conceptual standpoint -- the usage patterns with Vue 3 is pretty nearly identical for most people. You just replace "data()" property with some "reactive()" state value in setup (or "ref()" for single values).

You CAN write things like generic hooks/"useXXX()" helpers, but you likely won't wind up with a ton of those.

Also, about the reference passing: it doesn't actually really work like that. If you pass a "ref()" or "reactive()" value as a prop to a child component, and you mutate it there, it doesn't propagate to the parent.

Vue will throw this warning:

    [Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders. Instead, use a data or computed property based on the prop's value. Prop being mutated: "someRef"


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: