Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

use-immer-ref

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

use-immer-ref

library that manage your state more conveniently with immer and useRef

  • 1.0.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
21
Maintainers
1
Weekly downloads
 
Created
Source

use-immer-ref

Manage state with immer, useRef more conveniently!

Install

$ npm install immer use-immer-ref
$ yarn add immer use-immer-ref

Usage

import { useImmerRef } from 'use-immer-ref';

const ExampleComponent = () => {
  const [state, setState, ref] = useImmerRef({
    count: 0,
  })
  return (
    <div>
      <button onClick={() => {
          setState(dr => {
            dr.count = 1;
          })
          console.log(ref.current.count) // console.log result => 1
          // ref.current will be changed to the latest value immediately
        }}>
        add count
      </button>
      <div>
        count is {state.count}
      </div>
    </div>
  );
};

Keywords

FAQs

Package last updated on 16 Aug 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