@ferdotnet/use-forwarded-ref
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

A custom hook for react: useForwardedRef

Demo (Codepen)

https://codepen.io/ferdotnet/pen/gOKKxNr

Install

yarn add @ferdotnet/use-forwarded-ref

How to use it?

const Button = forwardRef(({ text }, ref) => {
  const safeRef = useForwardedRef(ref);
  useRipple(safeRef);
  
  return (
    <button className="button" ref={safeRef as React.RefObject<HTMLButtonElement>}>
      {text}
    </button>
  );
});

Readme

Keywords

none

Package Sidebar

Install

npm i @ferdotnet/use-forwarded-ref

Weekly Downloads

0

Version

0.0.3

License

MIT

Unpacked Size

2.34 kB

Total Files

6

Last publish

Collaborators

  • ferdotnet