From b3771facbd1226606792773d8e2a1e55b6f7935e Mon Sep 17 00:00:00 2001 From: Meghea Iulian Date: Wed, 13 Nov 2024 11:04:15 +0200 Subject: [PATCH] feat(use-hash-state): read initial value Pipe initial value thru read to make sure we encode it correctly. --- lib/use-hash-state.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/use-hash-state.js b/lib/use-hash-state.js index dbc8c979..7f8d1438 100644 --- a/lib/use-hash-state.js +++ b/lib/use-hash-state.js @@ -41,7 +41,7 @@ export const useHashState = (initial, param, { suffix = '', read, write, multi } const [link, parseHash] = multi ? [multiLink, multiParse] : [singleLink, singleParse], [state, _setState] = useState(() => param == null - ? initial + ? read(initial) : parseHash(param + suffix, read) ?? initial), setState = useCallback(state => _setState(oldState => {