{"id":13450543,"url":"https://github.com/robcalcroft/react-use-input","last_synced_at":"2025-04-10T19:50:42.368Z","repository":{"id":34297147,"uuid":"175450657","full_name":"robcalcroft/react-use-input","owner":"robcalcroft","description":"🎣 A hook whose setter can be directly given to HTML inputs","archived":false,"fork":false,"pushed_at":"2023-03-04T03:20:10.000Z","size":325,"stargazers_count":6,"open_issues_count":4,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-18T13:26:10.685Z","etag":null,"topics":["controlled","hooks","input","react","react-hooks"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/robcalcroft.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2019-03-13T15:39:35.000Z","updated_at":"2022-08-26T13:15:34.000Z","dependencies_parsed_at":"2024-04-11T21:48:52.743Z","dependency_job_id":"b9fe20c0-758e-43ea-a4b6-c501de133b8f","html_url":"https://github.com/robcalcroft/react-use-input","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robcalcroft%2Freact-use-input","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robcalcroft%2Freact-use-input/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robcalcroft%2Freact-use-input/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robcalcroft%2Freact-use-input/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/robcalcroft","download_url":"https://codeload.github.com/robcalcroft/react-use-input/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248283074,"owners_count":21077765,"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":["controlled","hooks","input","react","react-hooks"],"created_at":"2024-07-31T07:00:35.842Z","updated_at":"2025-04-10T19:50:42.333Z","avatar_url":"https://github.com/robcalcroft.png","language":"JavaScript","funding_links":[],"categories":["Packages"],"sub_categories":[],"readme":"# react-use-input\nA hook :fishing_pole_and_fish: whose setter can be directly given to HTML inputs\n\nThis package is designed to be super simple and small; it won't add any bloat to your project. However, feel free to copy and paste the [code](https://raw.githubusercontent.com/robcalcroft/react-use-input/master/index.js) if you'd like to avoid another dependency :smile:\n\nOther packages use object spread syntax to achieve a similar result, but this package doesn't because:\n- This way is much easier to read\n- You don't end up with bloat in your props for super simple use cases\n\n## Install\n```\nyarn add react-use-input\n```\n\n## Use\nBy default, `useInput()` returns a tuple of the current value and a setter which will pick the `value` key out of an `Event` object.\n\n```javascript\nuseInput(\u003cinitialValue (defaults to '') (optional)\u003e, \u003cvalueKey (defaults to 'value') (optional)\u003e)\n```\n\n**A simple example**\n\n```javascript\nimport useInput from 'react-use-input';\n\nfunction Component() {\n  const [name, setName] = useInput();\n  \n  return \u003cinput value={name} onChange={setName} /\u003e;\n}\n```\n\n**Checkbox type input with non default state**\n\n```javascript\nimport useInput from 'react-use-input';\n\nfunction Component() {\n  const [selected, setSelected] = useInput(false, 'checked');\n  \n  return (\n    \u003cinput type=\"checkbox\" checked={selected} onChange={setSelected} /\u003e\n  );\n}\n```\n\nFeel free to raise an issue to discuss other use cases that aren't covered here\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobcalcroft%2Freact-use-input","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobcalcroft%2Freact-use-input","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobcalcroft%2Freact-use-input/lists"}