0.2.2 • Published 5 years ago

@postinumero/use-query-param-with-default-value v0.2.2

Weekly downloads
23
License
ISC
Repository
github
Last release
5 years ago

@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
);