1.0.1 • Published 3 years ago

@jswork/class-imperative-handle v1.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

class-imperative-handle

React useImperativeHandle for class component.

version license size download

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.