1.0.1 • Published 6 years ago

react-promise-hook v1.0.1

Weekly downloads
6
License
ISC
Repository
github
Last release
6 years ago

React Promise Hook

React hook with the promise that gives you an ability to react on after set effect

Usage

import usePromiseHook from 'react-promise-hook'

const App = () => {
  const [test, setTest] = usePromiseHook(0)

  if (!test) {
    setTimeout(() => {
      setTest(42).then(() => console.log('UPDATED'))
    }, 2000)
  }

  return (
    <div className="App">
      <header className="App-header">
        <span role="img" aria-label="img">
          🤓
        </span>
        The Answer is {test}
      </header>
    </div>
  )
}

export default App

Demo

demo

Installation

 npm i react-promise-hook

or

 yarn add react-promise-hook

Made with ♥ by nudelx