use-state-promise
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

Use State Promise

Star IT Ltd

An enhanced version of useState hook that returns asynchronous setter. Written in TS.

Installation & Usage

yarn add use-state-promise

import useStatePromise from 'use-state-promise';

export default function App() {
  const [data, setDataPromise, setData] = useStatePromise(10);
  return (
    <>
      <p>{data}</p>
      <button
        onClick={() =>
          setDataPromise((curr) => curr + 1).then((state) => console.log('dom updated', state))
        }
      >
        click me!
      </button>
    </>
  );
}

Dependencies (0)

    Dev Dependencies (14)

    Package Sidebar

    Install

    npm i use-state-promise

    Weekly Downloads

    104

    Version

    0.1.1

    License

    MIT

    Unpacked Size

    9.27 kB

    Total Files

    14

    Last publish

    Collaborators

    • kuasha420