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

@airma/react-hooks

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@airma/react-hooks

This is a common react hook package

  • 15.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8
decreased by-55.56%
Maintainers
1
Weekly downloads
 
Created
Source

npm NPM downloads standard

@airma/react-hooks

It is a simple tool for providing some simple and useful react hooks for @airma/react-* tools. You can use it too.

API

usePersistFn

export declare function usePersistFn<T extends (...args: any[]) => any>(
  callback: T
): T;

This hook is created for replacing useCallback, if you want to create a persist callback.

import {memo} from 'react';
import {usePersistFn} from '@airma/react-hooks';

const App = memo((props: {onChange: (value:string)=>void})=>{
    return ...;
});

const Layout = ()=>{
    const call = usePersistFn((v: string)=>{});

    return <App onChange={call}/>
}

useMount

export declare function useMount(callback: () => (() => void) | void): void;

This hook is created for listen the mount effect of functional component.

useUpdate

export declare function useUpdate<T extends any[]>(
  callback: (prevDeps: undefined | T) => (() => void) | void,
  deps?: T
): void;

This hook is created for listen the update effect of functional component.

import {memo, useState} from 'react';
import {useUpdate} from '@airma/react-hooks';

const App = memo((props: {value:number})=>{

    const [count, setCount] = useState(props.value);

    useUpdate((prev)=>{
        if(!prev){
            return;
        }
        const [prevValue] = prev;
        console.log(prevValue)
    }, [props.value]);

    return ...;
});

useUnmount

export declare function useUnmount(destroy: () => void): void;

This hook is created for listen the unmount effect of functional component.

Keywords

FAQs

Package last updated on 04 Jul 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