1.0.1 • Published 7 years ago
react-promise-hook v1.0.1
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 AppDemo

Installation
 npm i react-promise-hookor
 yarn add react-promise-hookMade with ♥ by nudelx