# uselazyref

> A useRef React hook that supports lazy initialization.

Latest version **1.0.3** (published 2019-10-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install uselazyref
pnpm add uselazyref
yarn add uselazyref
bun add uselazyref
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2019-10-17 |
| First published | 2019-10-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 3.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | vlopp |
| Maintainers | vlopp |
| Keywords | react, react-hooks, useref lazy |

## Links

- npm: https://www.npmjs.com/package/uselazyref
- Repository: https://github.com/vlopp/useLazyRef
- Homepage: https://github.com/vlopp/useLazyRef#readme
- Issues: https://github.com/vlopp/useLazyRef/issues
- npm.io page: https://npm.io/package/uselazyref

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.3 (latest) — 2019-10-17
- 1.0.2 — 2019-10-17
- 1.0.1 — 2019-10-17
- 1.0.0 — 2019-10-17

## README

# useLazyRef

A wrapper to React's own `useRef` to support lazy initialization. So far, lazy init is supported by `useState`, but not `useRef`. Once React updates `useRef`, this package becomes deprecated.

Caution: it does **not** support non-lazy initialization. In this case, you should use the standard `useRef` instead.

# Usage

```
const ref = useLazyRef(() => expensiveComputation());
```

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