0.0.1 • Published 1 year ago

react-hooks-force-update v0.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Tiny hook to support forceUpdate() behaviour.

npm

Install

yarn add react-hooks-force-update

or

npm i -S react-hooks-force-update

Usage

import useForceUpdate from 'react-hooks-force-update'
import {useEffect} from "react";

function App() {
  const [value, forceUpdate] = useForceUpdate()

  console.log('App render')
  
  useEffect(() => {
    console.log('useEffect is updated')
  }, [value])

  useEffect(() => {
      const interval = setInterval(() => forceUpdate(), 1000)
      return () => clearInterval(interval)
  })
}