Skip to content

Commit

Permalink
chore: handle missing read
Browse files Browse the repository at this point in the history
  • Loading branch information
megheaiulian committed Nov 13, 2024
1 parent b3771fa commit 5b43cd8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/use-hash-state.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down

0 comments on commit 5b43cd8

Please sign in to comment.