Repository navigation
Two bug fixes, both from @rawsun007, and both the same shape: code that could never run. A regex alternation that wasn't one, and a branch behind a condition that was always true.
🐞 Bug Fixes
useMobileLandscape: detects Android tablets again
The alternation between Android and iphone was a fullwidth vertical line (|, U+FF5C) rather than |, so the two were a single literal that no user agent contains:
// 6.5.8: /Mobi|Android|iphone/i — `Mobi` was the only real alternative
// Now: /Mobi|Android|iPhone/iiPhones still matched, because their user agent carries a Mobile token. Android devices that don't — tablets — were never detected as mobile, so useMobileLandscape stayed false for them however the device was held. (#228)
useTextDirection: reads the element's direction on the first render
initialValue was destructured with a default of 'ltr', so the initialValue !== undefined guard above it was always true, and both the branch that reads the target element's dir and the server-side warning below it were unreachable:
// <html dir="rtl">
const [dir] = useTextDirection()
// 6.5.8: "ltr" on the first render, corrected to "rtl" by an effect
// Now: "rtl" on the first renderThe element wins now, falling back to initialValue and then 'ltr' — which is what the unreachable branch already did.
Two consequences worth knowing:
initialValueis a fallback, not an initial value. It applies only when the target element carries nodir. The docs and the API table describe it that way now.- The SSR warning is live again. The server can't read the element, so it still returns
initialValue, while the client reads the element on its first render. If you server-render without passinginitialValue, the hook now tells you to set it instead of letting the two sides disagree quietly.
(#230)
Full changelog: v6.5.8...v6.5.9