New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

react-mutable-refs

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

react-mutable-refs

React utility to create mutable ref or function

latest
Source
npmnpm
Version
4.1.0
Version published
Weekly downloads
11
-21.43%
Maintainers
1
Weekly downloads
 
Created
Source

react-mutable-refs

react-mutable-refs provides utility to create mutable ref or function. This helps you in avoiding unwanted React re-renders.

Install

yarn add react-mutable-refs

or

npm i react-mutable-refs

Usage


import { useMutableFunc, useMutableRef } from 'react-mutable-refs'

function ExamplePage(props) {
  const { item } = props
  const mutableItemRef = useMutableRef(item)

  // myFunciton will not re-render due to any change item
  const myFunction = React.useCallback(() => {
    if (mutableItemRef.current) {
      // do something
    }
  }, [mutableItemRef])


}


function useExampleHook(props) {
  const { prop1, prop2 } = props

  const someFunction = React.useCallback(() => {
    if (prop1 && prop2) {
      // do something
    }
  }, [prop1, prop2])

  
  const mutableFunc = useMutableFunc(someFunction)
  // mutableFunc is not affected by prop1, prop2 etc. and avoid unwanted re-render of React.
  return mutableFunc
}

Components/Hooks/Functions

  • useMutableRef
  • useMutableFunc
  • mergeRefs
  • assignRefs
  • trackDefaultRef
  • trackLastRef
  • Refreshable
  • makeRefreshable

Author

Prolincur Technologies

Keywords

react

FAQs

Package last updated on 03 Apr 2024

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