1.1.3 • Published 1 year ago

ref-component v1.1.3

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

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} />
}
1.1.3

1 year ago

1.1.2

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago