# use-force-update

> React hook to force your function component to re-render

Latest version **2.0.0** (published 2025-05-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install use-force-update
pnpm add use-force-update
yarn add use-force-update
bun add use-force-update
```

## Health

**Score 60/100 (C)** — status: stable.

Positive: has types; esm support; no vulnerabilities; has provenance; high maintenance score; high quality score.

Warnings: low downloads.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2025-05-25 |
| First published | 2018-10-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 31 |
| Author | quisi.do |
| Maintainers | charlesstover |

## Links

- npm: https://www.npmjs.com/package/use-force-update
- Repository: https://github.com/quisido/quisi.do
- Homepage: https://github.com/quisido/quisi.do/tree/main/packages/use-force-update#readme
- Issues: https://github.com/quisido/quisi.do/issues
- Funding: https://github.com/sponsors/quisido
- npm.io page: https://npm.io/package/use-force-update

## Recent versions

- 2.0.0 (latest) — 2025-05-25
- 1.0.11 — 2022-11-30
- 1.0.10 — 2022-07-21
- 1.0.9 — 2022-07-18
- 1.0.8 — 2022-05-01
- 1.0.7 — 2019-07-13
- 1.0.6 — 2019-06-23
- 1.0.5 — 2019-04-27
- 1.0.4 — 2019-03-11
- 1.0.3 — 2019-02-28
- 1.0.2 — 2019-02-11
- 1.0.1 — 2019-01-31
- 1.0.0 — 2018-10-26

## README

# useForceUpdate

[![version](https://img.shields.io/npm/v/use-force-update.svg)](https://www.npmjs.com/package/use-force-update)
[![minzipped size](https://img.shields.io/bundlephobia/minzip/use-force-update.svg)](https://www.npmjs.com/package/use-force-update)
[![downloads](https://img.shields.io/npm/dt/use-force-update.svg)](https://www.npmjs.com/package/use-force-update)

`useForceUpdate` is a React hook that you can call to force a function 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`

## Usage

In its simplest form, `useForceUpdate` re-renders a component.

```jsx
import useForceUpdate from 'use-force-update';

let renderCount = 0;

export default function MyButton() {
  const forceUpdate = useForceUpdate();

  renderCount++;
  return (
    <>
      <p>I have rendered {renderCount} times.</p>
      <button onClick={forceUpdate}>
        Re-render
      </button>
    </>
  );
};
```

In its ideal form, `useForceUpdate` integrates with event emitters, such as
state managers.

```jsx
import { useEffect } from 'react';
import useForceUpdate from 'use-force-update';
import store from './store';

export default function MyButton() {
  const forceUpdate = useForceUpdate();

  const username = store.get('username');

  useEffect(() => {
    // When the username changes, re-render this component.
    const selector = state => state.username;
    const unsubscribe = store.subscribe(selector, forceUpdate);

    // When we unmount, stop re-rendering this component.
    return () => {
      unsubscribe();
    };
  }, [forceUpdate]);

  if (username === null) {
    return <p>You are not logged in.</p>;
  }

  return <p>Hello, {username}!</p>;
};
```

---
_Source: https://npm.io/package/use-force-update · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
