Migrating from v1 and v2
Migrating from v2
| v2 | v3 |
|---|---|
const { category } = useQuery() | const { params: { category } } = useQuery<"category">() |
QueryParams was Readonly<Record<string, string>> | QueryParams<K> is Readonly<Partial<Record<K, string>>> (values may be undefined) |
| no way to read repeated keys | useQuery().getAll(key) |
useClickOutside(ref, handler) | unchanged; also accepts an array of refs and { enabled } |
useCountdown(target) | unchanged; also accepts { onExpire }. Countdown fields are readonly |
Migrating from v1
| v1 | v3 |
|---|---|
useCountdownDate(date) | useCountdown(date), which also returns totalMilliseconds and isExpired |
useOnClickOutSide(ref, handler) | useClickOutside(ref, handler) |
useOutsideElement({ ref, callback }) | useClickOutside(ref, callback) |
useQuery() | useQuery().params, which now updates on back/forward navigation |
ParamsType, CountDownDateType | QueryParams, Countdown |
Other changes since v1:
- React 18 or newer is required (the hooks use
useSyncExternalStore). - A past or invalid date no longer logs a console error. It is reported as
isExpired: true. useClickOutsidenow listens for touches as well as mouse presses.