Socket
Socket
Sign inDemoInstall

@bedrock-layout/use-stateful-ref

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bedrock-layout/use-stateful-ref

bedrock-layout useStatefulRef


Version published
Maintainers
1
Created
Source

@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>;
};

Keywords

FAQs

Package last updated on 15 Oct 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc