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

ikeyit-react-easy

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ikeyit-react-easy

Lightweight hooks for React

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

Install

npm install ikeyit-react-easy

Quickstart

useAsync

The hook is used to track status of an async action. When the action starts, the status becomes to be "loading". You can show a loading indicator or disable some UI components. When the action is finished successfully, the status becomes to be "success". You can show the "data". If the action fails, the status will be "error". You can toast the error to the user.
If the action is executed many times simultaneously, only the latest data is returned.

import { useAsync } from 'ikeyit-react-easy';
function YourComponent() {
    const {data, error, status, execute} = useAsync(
        params => asyncMethod(params),
        { 
            onSuccess: () => {},
            onError: () => {}
        }
    );
    return (
        <>
        <div>status: {status}</div>
        <div>data: {data}</div>
        <div>error: {error}</div>
        <button onClick={e => execute()}>Run slow async action</button>
        </>
    ); 
}

Keywords

react

FAQs

Package last updated on 07 May 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