react-useStateRef icon indicating copy to clipboard operation
react-useStateRef copied to clipboard

Export types

Open jackcannon opened this issue 1 year ago • 1 comments

Having access the the types without hoop jumping is useful.

Zero logic changes, nothing new, just exporting some existing types.

import useStateRef, {ReadOnlyRefObject} from 'react-usestateref';

const SomeComponent = () => {
  const [year, setYear, yearRef] = useStateRef<number>(undefined);

  const doSomething = (ref: ReadOnlyRefObject<number>) => {
    // doing something with ref.current
  }

  doSomething(yearRef);

  // etc
}

jackcannon avatar Mar 05 '23 16:03 jackcannon