@jswork/class-imperative-handle
v1.0.1
Published
React `useImperativeHandle` for class component.
Downloads
143
Maintainers
Readme
class-imperative-handle
React
useImperativeHandle
for class component.
installation
npm install @jswork/class-imperative-handle
usage
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 (
<div
ref={this.handleRef}
{...this.props}
/>
);
}
}
license
Code released under the MIT license.