mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-25 20:44:49 -04:00
fix(explore): URL parameters override default value
Signed-off-by: Erik Michelson <github@erik.michelson.eu>
This commit is contained in:
parent
485ac5a7a6
commit
0df149aba3
1 changed files with 5 additions and 2 deletions
|
@ -62,13 +62,16 @@ export const useUrlParamState = <T extends string | null = string>(
|
|||
if (!searchParamsReact) {
|
||||
return
|
||||
}
|
||||
const newValue = searchParamsReact.get(paramName) as T
|
||||
let newValue = searchParamsReact.get(paramName) as T
|
||||
if (newValue === null) {
|
||||
newValue = typeof defaultValue === 'function' ? defaultValue() : defaultValue
|
||||
}
|
||||
if (newValue === lastSetValue.current) {
|
||||
return
|
||||
}
|
||||
lastSetValue.current = newValue
|
||||
setValue(newValue)
|
||||
}, [paramName, searchParamsReact])
|
||||
}, [paramName, searchParamsReact, defaultValue])
|
||||
|
||||
return [value, onUpdate]
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue