@bedrock-layout/use-stateful-ref
    TypeScript icon, indicating that this package has built-in type declarations

    1.1.10 • Public • Published

    @bedrock-layout/use-stateful-ref

    Full docs at: bedrock-layout.dev

    React RefObjects are not stateful, or in other words, changing the current property on the RefObject doesn't trigger a rerender. One can use a ref callback to updated state, but now we are no longer using RefObjects and there is great power in consistency and knowing we will be getting a RefObject every time. useStatefulRef will return a RefObject that can be passed around and used just like anyother RefObject, except that changes to the current property will trigger a refrender just like updating state.

    Usage

      npm install @bedrock-layout/use-stateful-ref
    import useStatefulRef from '@bedrock-layout/use-stateful-ref';
    
    const App = () => {
      const ref = useStatefulRef(null);
      //... Use the ref object will trigger a rerender
      return <Div ref={ref}>{...content}</Div>;
    };

    Install

    npm i @bedrock-layout/use-stateful-ref

    DownloadsWeekly Downloads

    8,456

    Version

    1.1.10

    License

    MIT

    Unpacked Size

    9.23 kB

    Total Files

    12

    Last publish

    Collaborators

    • jarvis1010