{"id":22220543,"url":"https://github.com/drawbotics/drawbotics-use-filters","last_synced_at":"2025-03-25T07:41:30.030Z","repository":{"id":189410391,"uuid":"227122513","full_name":"Drawbotics/drawbotics-use-filters","owner":"Drawbotics","description":"Hook to manage filter values and keep them in sync with the url","archived":false,"fork":false,"pushed_at":"2022-06-08T10:28:46.000Z","size":106,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-12-22T03:07:54.867Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Drawbotics.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2019-12-10T13:03:04.000Z","updated_at":"2023-08-19T20:37:06.000Z","dependencies_parsed_at":null,"dependency_job_id":"d2576208-dd57-4936-9734-6b77b4f50f7b","html_url":"https://github.com/Drawbotics/drawbotics-use-filters","commit_stats":null,"previous_names":["drawbotics/drawbotics-use-filters"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Drawbotics%2Fdrawbotics-use-filters","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Drawbotics%2Fdrawbotics-use-filters/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Drawbotics%2Fdrawbotics-use-filters/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Drawbotics%2Fdrawbotics-use-filters/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Drawbotics","download_url":"https://codeload.github.com/Drawbotics/drawbotics-use-filters/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245422921,"owners_count":20612725,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-02T23:09:02.672Z","updated_at":"2025-03-25T07:41:30.001Z","avatar_url":"https://github.com/Drawbotics.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Use Filters\n\nHook to read/set filter values from/in the url.\n\n## Installation\n\n```bash\n$ npm i @drawbotics/use-filters\n```\n\n## Usage\n\n### TypeScript\n\n```tsx\nimport { useFilters } from '@drawbotics/use-filters';\n\ninterface Filters {\n  filterKey: string;\n  filterKey2: 'one-value' | 'another-value';\n}\n\n// ... inside a component ...\nconst { filterKey, filterKey2 } = useFilter\u003cFilters\u003e(\n  location,\n  history,\n  ['filterKey', 'filterKey2'],\n  (key, value) =\u003e `Updated ${key} with ${value}`,\n);\n\n// read a filter value\nconsole.log(filterKey.value); // =\u003e filterValue\n\n// or an array value\nconsole.log(filterKey.values); // =\u003e [filterValue]\n\n// set a value\nfilterKey.set('newValue');\n```\n\n### JavaScript\n\n```jsx\nimport { useFilters } from '@drawbotics/use-filters';\n\n// ... inside a component ...\nconst { filterKey, filterKey2 } = useFilter(\n  location,\n  history,\n  ['filterKey', 'filterKey2'],\n  (key, value) =\u003e `Updated ${key} with ${value}`,\n);\n\n// read a filter value\nconsole.log(filterKey.value); // =\u003e filterValue\n\n// or an array value\nconsole.log(filterKey.values); // =\u003e [filterValue]\n\n// set a value\nfilterKey.set('newValue');\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrawbotics%2Fdrawbotics-use-filters","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdrawbotics%2Fdrawbotics-use-filters","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrawbotics%2Fdrawbotics-use-filters/lists"}