giao-hook
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

usage

import React, { useEffect, useState } from 'react'
import { useAsyncGetState } from 'giao-hook' 

function App() {
  const [count1, setCount1, getCount1] = useAsyncGetState(10)
  const [count2, setCount2] = useState(0)

  async function changeCount1() {
    await setCount1(count1 + 1)
  }
  function changeCount2() {
    setCount2(getCount1() * 10)
  }

  useEffect(() => {
    changeCount1()
    changeCount2()
  }, [])

  return (
    <div> 
      <h2>count1: { count1 }</h2>
      <h2>count2: { count2 }</h2> 
    </div>
  );
}

export default App;

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i giao-hook

      Weekly Downloads

      14

      Version

      1.0.4

      License

      MIT

      Unpacked Size

      3.1 kB

      Total Files

      4

      Last publish

      Collaborators

      • vear