@postinumero/use-query-param-with-default-value
v0.2.2
Published
Like `useQueryParam` `use-query-params`, but if current value is same as the default, param is removed from the URL.
Downloads
106
Readme
@postinumero/use-query-param-with-default-value
Like useQueryParam
from use-query-params, but if current value is same as the default, param is removed from the URL.
Install
npm install @postinumero/use-query-param-with-default-value use-query-params query-string
Example
import useQueryParamWithDefaultValue from '@postinumero/use-query-param-with-default-value';
import { BooleanParam } from 'use-query-params';
// …
const defaultValue = 1;
const [myBoolean, setMyBoolean] = useQueryParamWithDefaultValue(
defaultValue,
'myBoolean',
BooleanParam
);