Vue3/Pinia computed from storeToRefs
16:54 02 Mar 2023

I have a situation where I need to create a computed property from a pinia store getter -

import { computed} from 'vue'
import { storeToRefs } from 'pinia'
import {useMyStore} from './../stores/mystore'
export default {
  setup() {
    const { sessionUser } = storeToRefs(useMyStore())
    const fullName = computed( () => 
      `${ sessionUser.value.value.firstName } ${ sessionUser.value.value.lastName }`
    )
    return {
      fullName
    }
  }
}

Obviously the value.value is clunky, and I'd rather not move the computed property down into the store itself. I know why the vale.value is necessary, but is there any better way to set up a computed reactive property in a component that is based on a store value (which is also a computed property within the store)?

vuejs3 computed-properties pinia