From 5b43cd87d5c03858c21b1555031696dc4d053c6f Mon Sep 17 00:00:00 2001 From: Meghea Iulian Date: Wed, 13 Nov 2024 11:12:11 +0200 Subject: [PATCH] chore: handle missing read --- lib/use-hash-state.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/use-hash-state.js b/lib/use-hash-state.js index 7f8d1438..aa5b3741 100644 --- a/lib/use-hash-state.js +++ b/lib/use-hash-state.js @@ -40,8 +40,9 @@ const export const useHashState = (initial, param, { suffix = '', read, write, multi } = {}) => { const [link, parseHash] = multi ? [multiLink, multiParse] : [singleLink, singleParse], + // eslint-disable-next-line no-nested-ternary [state, _setState] = useState(() => param == null - ? read(initial) + ? (read ? read (initial): initial) : parseHash(param + suffix, read) ?? initial), setState = useCallback(state => _setState(oldState => {