@bedrock-layout/use-forwarded-ref

bedrock-layout useForwardedRef

Usage no npm install needed!

<script type="module">
  import bedrockLayoutUseForwardedRef from 'https://cdn.skypack.dev/@bedrock-layout/use-forwarded-ref';
</script>

README

@bedrock-layout/use-forwarded-ref

When you need to use a ref and use are useing for

Full docs at: bedrock-layout.dev

Usage

import useForwardedRef from '@bedrock-layout/use-forwarded-ref';

const ForwardedRefDiv = React.forwardRef((props,ref)=>{
    const innerRef = useForwardedRef(ref)
    // do something with innerRef
    return <div ref={innerRef} {...props}>
})

Then in your app you would use it like this:

const App = () => {
  const ref = React.useRef(null);
  console.log(ref.current);
  return <ForwardedRefDiv ref={ref}>{...content}</ForwardedRefDiv>;
};