ref-component
TypeScript icon, indicating that this package has built-in type declarations

1.1.3 • Public • Published

ref-Component

完整文档(FULL DOC)

An library to quickly customize the exposed instance value when using ref.

Download

pnpm install ref-component
npm install ref-component
yarn add ref-component

Useage

import { defineComponent, ComponentRef } from 'ref-component'
// define Component
const Dashboard = defineComponent(({ name }: { name: string }) => {
  const [person, setPerson] = useState(name)
  return {
    setPerson,
    element: <div>{person}</div>
  }
})

// use
const App = () => {
  const dashboardRef = useRef<ComponentRef<typeof Dashboard>>(null)
  useEffect(() => {
    setTimeout(() => {
      dashboardRef.current.setPerson('小李')
    }, 3000)
  }, [])
  return <Dashboard name="小王" ref={dashboardRef} />
}

/ref-component/

    Package Sidebar

    Install

    npm i ref-component

    Weekly Downloads

    8

    Version

    1.1.3

    License

    MIT

    Unpacked Size

    14.7 kB

    Total Files

    13

    Last publish

    Collaborators

    • luoanbing