https://github.com/afeiship/class-imperative-handle
React `useImperativeHandle` for class component.
https://github.com/afeiship/class-imperative-handle
forwardref react ref useimperativehandle
Last synced: 3 days ago
JSON representation
React `useImperativeHandle` for class component.
- Host: GitHub
- URL: https://github.com/afeiship/class-imperative-handle
- Owner: afeiship
- License: mit
- Created: 2019-11-03T07:43:13.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-09-05T02:02:58.000Z (almost 4 years ago)
- Last Synced: 2025-01-06T08:08:09.112Z (5 months ago)
- Topics: forwardref, react, ref, useimperativehandle
- Language: JavaScript
- Homepage:
- Size: 213 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# class-imperative-handle
> React `useImperativeHandle` for class component.[![version][version-image]][version-url]
[![license][license-image]][license-url]
[![size][size-image]][size-url]
[![download][download-image]][download-url]## installation
```shell
npm install @jswork/class-imperative-handle
```## usage
```js
import classImperativeHandle from '@jswork/class-imperative-handle';class MyComponent extends Component {
handleRef = (inRoot) => {
const { forwardedRef } = this.props;
classImperativeHandle(forwardedRef, inRoot);
this.root = inRoot;
};render() {
return (
);
}
}export default React.forwardRef((props: ReactCheckboxProps, ref: any) => (
));
```## license
Code released under [the MIT license](https://github.com/afeiship/class-imperative-handle/blob/master/LICENSE.txt).[version-image]: https://img.shields.io/npm/v/@jswork/class-imperative-handle
[version-url]: https://npmjs.org/package/@jswork/class-imperative-handle[license-image]: https://img.shields.io/npm/l/@jswork/class-imperative-handle
[license-url]: https://github.com/afeiship/class-imperative-handle/blob/master/LICENSE.txt[size-image]: https://img.shields.io/bundlephobia/minzip/@jswork/class-imperative-handle
[size-url]: https://github.com/afeiship/class-imperative-handle/blob/master/dist/class-imperative-handle.min.js[download-image]: https://img.shields.io/npm/dm/@jswork/class-imperative-handle
[download-url]: https://www.npmjs.com/package/@jswork/class-imperative-handle