JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 29378
  • Score
    100M100P100Q145806F
  • License MIT

React Hook to force your function component to update.

Package Exports

  • use-force-update

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (use-force-update) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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} />;
};