npm

Need private packages and team management tools?Check out npm Orgs. »

use-force-update

1.0.7 • Public • Published

useForceUpdate Tweet version minzipped size downloads build

useForceUpdate is a React Hook that forces your functional component to re-render.

useForceUpdate does not serve a purpose in and of itself. It is a tiny package that aims to be integrated into larger hooks, making obsolete any class functionality that is still reliant on this.forceUpdate.

Install

  • npm install use-force-update or
  • yarn add use-force-update

Use

import useForceUpdate from 'use-force-update';
 
const MyButton = () => {
 
  const forceUpdate = useForceUpdate();
 
  const handleClick = () => {
    alert('I will re-render now.');
    forceUpdate();
  };
 
  return <button onClick={handleClick} />;
};

Keywords

none

install

npm i use-force-update

Downloadsweekly downloads

28,054

version

1.0.7

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability