New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

use-effect-x

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-effect-x

An alternative to useEffect which provide extra info to work with updates and react on what changed

  • 0.1.0
  • npm
  • Socket score

Version published
Weekly downloads
234
decreased by-12.03%
Maintainers
1
Weekly downloads
 
Created
Source

use-effect-x

An alternative to useEffect which provide extra info to work with updates and react on what changed


Install

If you use yarn. Run


yarn add use-effect-x

If you use npm. Run


npm i use-effect-x

Usage

import { useEffectX } from 'use-effect-x';

export default function App() {
  const [countA, setCountA] = React.useState(0);
  const [countB, setCountB] = React.useState(0);

  useEffectX(
    ({ changedItem }) => {
      // Here you have complete access to what changed
      console.log('changed Item', changedItem);
      // your logic if you want to check for count
      console.log(
        `count ${changedItem[0]?.changed ? 'changed' : 'not changed'} from ${
          changedItem[0]?.previous
        } to ${changedItem[0]?.next}`
      );
    },
    [countA, countB]
  );

  return (
    <div className="App">
      countA -> {countA}
      countB -> {countB}
      <button
        onClick={() => {
          setCountA(countA + 1);
        }}
      >
        Change count A
      </button>
      <button
        onClick={() => {
          setCountB(countB + 1);
        }}
      >
        Change count B
      </button>
    </div>
  );
}

FAQs

Package last updated on 13 Aug 2020

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