diff --git a/lib/use-hash-param.js b/lib/use-hash-param.js index b9090f6..30f04f7 100644 --- a/lib/use-hash-param.js +++ b/lib/use-hash-param.js @@ -41,5 +41,16 @@ export const link = (hashParam, value) => { }; }, [parameterized]); - return param; + const set = useMemo( + () => + hashParam + ? (v) => { + setParam(v); + history.pushState({}, '', link(v)); + } + : setParam, + [hashParam] + ); + + return [param, set]; };