@iamcosta/url-params-hook
v2.1.0
Published
Map object props to url search parameters
Downloads
95
Readme
url-params-hook
What about map an object to url search parameters? :)
Installation
npm install @iamcosta/url-params-hook
# or
yarn add @iamcosta/url-params-hook
Usage
import { useUrlParams } from "@iamcosta/url-params-hook";
// ...
type YourType = {
someProp: string;
anotherProp: number;
}
const { values, onChange } = useUrlParams<YourType>({
ignoreKeys: ["keys", "of", "YourType", "to", "be", "ignored"]
});
// ignoreKeys is optional...
// ...
// This change url parameters...
onChange({
someProp: "some text",
// ...
});
// ... while this obtains the new value provided by url state in any place
const { someProp } = values;
License
MIT @ Iam Barroso da Costa