Skip to content

Commit

Permalink
feat(hash-param)!: add setter support
Browse files Browse the repository at this point in the history
  • Loading branch information
megheaiulian authored and cristinecula committed May 18, 2022
1 parent 0fcd9dc commit 2244cd6
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lib/use-hash-param.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
};

0 comments on commit 2244cd6

Please sign in to comment.