Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Ajvanho's avatar
Level 14

ref vs reactive

On the example from the vue js docs, we can see that it collects these states as refs. Should it be collected like this for a form or as a reactive object called form for example?

const text = ref('Edit me')
const checked = ref(true)
const checkedNames = ref(['Jack'])
const picked = ref('One')
const selected = ref('A')
const multiSelected = ref(['A'])
const form = reactive({
text: '',
...
})
0 likes
2 replies
MaverickChan's avatar

if you have a composable js handle the state management, use reactive , it keeps the objects working and you don't have to use .value.

if you are using a viriable in a template file only , use ref is fine. And don't foget put .value after

Please or to participate in this conversation.