Skip to content

v4.3.0

Choose a tag to compare

@github-actions github-actions released this 11 Oct 02:37
· 34 commits to main since this release
e4854fa

Version 4.3.0 – Adds a suite of new hooks for animation‑frame callbacks, clipboard, visibility, hover/focus tracking, latest refs, session storage, and improves element‑position measurement, while fixing a key‑press ignore bug.

Added

  • useAnimationFrameCallback – runs a callback once per animation frame with the last call’s arguments, returning [schedule, cancel].
  • useCopyToClipboard – copies text via navigator.clipboard.writeText and returns { copy, copied, error }. copied resets after resetDelay ms, each copy restarts the timer, and the timer clears on unmount.
  • useDocumentVisibility – returns whether the page is visible, useful for pausing timers and polling while a tab is in the background.
  • useHoverOrFocusWithin – tracks hover and focus‑within separately, returning { active, hovered, focusWithin, handlers }. active stays true while either flag is set, and moving focus between children does not toggle it.
  • useLatest – returns a ref that always holds the value from the latest committed render, for callbacks set up once (timers, listeners, observers) that need the newest props.
  • useSessionStorage – the sessionStorage counterpart of useLocalStorage. Both hooks now share one internal factory, with a separate cache and subscriber list per storage area.
  • useElementPosition enhancements – now accepts a getter function in addition to a ref or CSS selector, and a measure option that replaces getBoundingClientRect(). A getter is called on every measurement and after every render, allowing the element to change over time; existing ref and selector usage remains unchanged.

Fixed

  • useKeyPress – prevented a closest is not a function error when the ignore option is set and the keydown event target is window or document. Such events are now never treated as inside an ignored element.

What's Changed

  • docs: align the PR template with the shared Summary / Changes / How to test structure by @pjb0811 in #214
  • chore: run lint-staged through pnpm in the pre-commit hook by @pjb0811 in #215
  • chore: move pnpm settings from .npmrc to pnpm-workspace.yaml by @pjb0811 in #219
  • chore: upgrade pnpm from 10.28.0 to 12.8.1 by @pjb0811 in #220
  • chore: keep pnpm and dependencies up to date with Renovate by @pjb0811 in #221
  • chore: run Renovate in full mode with weekly lockfile maintenance by @pjb0811 in #222
  • docs(skill): add the comment-writing rules and the empty-changeset rule by @pjb0811 in #225
  • chore(website): update @jbpark/ui-kit from 9.1.1 to 10.1.0 by @pjb0811 in #226
  • feat: add useSessionStorage hook by @pjb0811 in #234
  • chore: add a test runner and baseline hook tests by @pjb0811 in #236
  • test: add tests for the timer hooks by @pjb0811 in #238
  • feat: add useLatest hook by @pjb0811 in #240
  • refactor: use useLatest for the hand-written latest-value refs by @pjb0811 in #242
  • test: add tests for the state hooks by @pjb0811 in #243
  • test: add tests for the event and browser API hooks by @pjb0811 in #245
  • test: add tests for the observer and layout hooks by @pjb0811 in #246
  • fix(useKeyPress): do not throw on a non-element event target with ignore by @pjb0811 in #247
  • feat: add useDocumentVisibility hook by @pjb0811 in #248
  • feat: add useCopyToClipboard hook by @pjb0811 in #249
  • chore: keep only repository-specific skills and point to the shared pjb0811/skills by @pjb0811 in #252
  • feat: add useHoverOrFocusWithin hook by @pjb0811 in #250
  • feat: add useAnimationFrameCallback hook by @pjb0811 in #253
  • feat(useElementPosition): accept an element getter and a custom measure function by @pjb0811 in #254
  • chore(deps): update eslint to v10, eslint-plugin-react-hooks to v7 and changesets/action to v2 by @pjb0811 in #255
  • chore: version packages by @github-actions[bot] in #235

Full Changelog: v4.2.0...v4.3.0