# @hmans/use-const

> A simple `useConst` hook for when you don't trust `useMemo`. ;-)

Latest version **0.0.1** (published 2022-08-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install @hmans/use-const
pnpm add @hmans/use-const
yarn add @hmans/use-const
bun add @hmans/use-const
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2022-08-18 |
| First published | 2022-08-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 3.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Hendrik Mans |
| Maintainers | hendrik.mans |

## Links

- npm: https://www.npmjs.com/package/@hmans/use-const
- npm.io page: https://npm.io/package/@hmans/use-const

## Recent versions

- 0.0.1 (latest) — 2022-08-18

## README

# @hmans/use-const

## Summary

`useConst`, a simple hook that allows you to define a contant value that will never change during the lifetime of the component.

```tsx
import { useConst } from "@hmans/use-const"

const MyComponent = () => {
  const foo = useConst(() => new Foo())
  /* ... */
}
```

## Motivation

Typically, you might use `useMemo` or `useState` for these things. `useMemo` doesn't give you a guarantee that it will never re-run its initializar function (which can be bad, depending on what kind of value you're dealing with), and `useState` adds state tracking overhead that sometimes is not needed.

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