Skip to content

About

React hooks for async loads that never land out of order, plus the small state hooks an app builds screens from.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

react-load-hooks

License: MIT npm TypeScript


React hooks for async loads that never land out of order, plus the small state hooks an app builds screens from. Package @rethunk/react-load-hooks. First consumer: Mortar.

Only the newest load lands: a slower, older answer or error never overwrites a newer one, and an unmounted component hears nothing.

const { data, loading, error, reload } = useLoaded(() => fetchRepos(owner), [owner], [])

Quick start

bun add @rethunk/react-load-hooks

A worked example and the contracts: HUMANS.md.

Features

  • useLoaded and useDebouncedLoad fetch on dependency changes and drop superseded answers.
  • loader is the same logic without React, for a store or a class.
  • useStoredState persists UI state in localStorage.
  • useWidth tracks an element's width before paint; useDebouncedValue settles a fast-changing value.
  • sameValue, keepUnchanged and keepFields keep the stored value when a fresh backend answer is equal, so subscribers do not re-render.
  • clockWhen, absoluteWhen and relativeWhen label a time through Intl: "3 minutes ago" within a week, a date after.
  • useNowValue and useSecondValue share one timer per period and re-render only on a changed answer.

Documentation

Doc Audience
HUMANS.md Running and using the package
AGENTS.md Internals, invariants, and why
CONTRIBUTING.md Process — commits, tests, docs
SECURITY.md Vulnerability disclosure
CHANGELOG.md Release notes

License

MIT — see LICENSE. © 2026 Rethunk.Tech, LLC.

About

React hooks for async loads that never land out of order, plus the small state hooks an app builds screens from.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages