v-forward-ref
v0.1.2
Published
Portal `React.forwardRef` api into Vue
Downloads
11
Readme
v-forward-ref
Install
via pnpm
, yarn
or npm
:
pnpm add v-forward-ref
# or
yarn add v-forward-ref
# or
npm i -S v-forward-ref
How to use
import { forwardRef } from 'v-forward-ref'
const Comp = defineComponent((props, ctx) => {
ctx.expose({ foo: 'bar' })
return () => <div>{props.message}</div>
})
const Wrap = forwardRef((props, { slots }, ref) => {
return <Comp {...props} ref={ref} v-slots={slots} />
})
const App = defineComponent(() => {
const cmpRef = ref(null)
onMounted(() => {
console.log(cmpRef.value.foo) // => 'bar'
})
return () => <Wrap message="Hello" ref={cmpRef} />
})
License
MIT © Mitscherlich