Skip to content

Latest commit

 

History

History
30 lines (24 loc) · 487 Bytes

use-ref.md

File metadata and controls

30 lines (24 loc) · 487 Bytes

useRef

Automatically infer type for useRef. It's an alias of shallowRef.

Basic Usage

import { defineComponent } from 'vue'
import { useRef } from 'vue-jsx-vapor'
// or
// import { shallowRef as useRef } from 'vue'

export const Comp = defineComponent({
  setup() {
    return { foo: 1 }
  },
})

export default defineComponent(() => {
  const comp = useRef()
  comp.value?.foo
  //           ^?

  return (
    <>
      <Comp ref={comp} />
    </>
  )
})