{"id":15434016,"url":"https://github.com/sebinsua/react-detect-event-outside","last_synced_at":"2026-04-20T04:02:41.199Z","repository":{"id":65483201,"uuid":"103426118","full_name":"sebinsua/react-detect-event-outside","owner":"sebinsua","description":"🎪🍃 `EventOutside` component for React.","archived":false,"fork":false,"pushed_at":"2017-09-24T22:54:12.000Z","size":469,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-30T10:05:57.807Z","etag":null,"topics":["blur","click","component","event","focus","forms","modals","outside","react"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/sebinsua.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-13T16:51:31.000Z","updated_at":"2017-09-22T21:58:24.000Z","dependencies_parsed_at":"2023-01-25T11:15:20.622Z","dependency_job_id":null,"html_url":"https://github.com/sebinsua/react-detect-event-outside","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/sebinsua/react-detect-event-outside","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebinsua%2Freact-detect-event-outside","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebinsua%2Freact-detect-event-outside/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebinsua%2Freact-detect-event-outside/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebinsua%2Freact-detect-event-outside/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sebinsua","download_url":"https://codeload.github.com/sebinsua/react-detect-event-outside/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebinsua%2Freact-detect-event-outside/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267705653,"owners_count":24130936,"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","status":"online","status_checked_at":"2025-07-29T02:00:12.549Z","response_time":2574,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["blur","click","component","event","focus","forms","modals","outside","react"],"created_at":"2024-10-01T18:36:44.216Z","updated_at":"2026-04-20T04:02:36.167Z","avatar_url":"https://github.com/sebinsua.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `react-detect-event-outside`\n\u003e `EventOutside` component for React.\n\nA component which detects `click`, `focus` and `touch` events outside from it and calls a function to handle the event.\n\n\u003e **NOTE**: We capture events at the `document` level and wish to support some events which [do not bubble](https://en.wikipedia.org/wiki/DOM_events#Events), for example to detect when elements outside a component have gained `focus`. In these situations we: (a) use the [`useCapture` argument of `addEventListener`](https://stackoverflow.com/questions/7398290/unable-to-understand-usecapture-attribute-in-addeventlistener), or (b) find a similar event which does bubble ([sometimes difficult](https://bugzilla.mozilla.org/show_bug.cgi?id=687787)).\n\n## Example\n\n### Using the `EventOutside` component\n\n```js\nimport React from 'react'\nimport EventOutside from 'react-detect-event-outside'\n\nconst onEvent = (evt, el) =\u003e console.log('event happened outside', evt, el)\n\nconst SomeComponent = () =\u003e (\n  \u003cdiv className=\"SomeComponent\"\u003e\n    \u003cEventOutside onEventOutside={onEvent}\u003e\n      \u003cdiv className=\"SomeComponent-inside\"\u003e\n        \u003ch2\u003eInside\u003c/h2\u003e\n        \u003cinput type=\"text\" /\u003e\n      \u003c/div\u003e\n    \u003c/EventOutside\u003e\n    \u003cdiv className=\"SomeComponent-outside\"\u003e\n      \u003ch2\u003eOutside\u003c/h2\u003e\n      \u003cinput type=\"text\" /\u003e\n    \u003c/div\u003e\n  \u003c/div\u003e\n)\n\nexport default SomeComponent\n```\n\n### Wrapping your own component with the `withEventOutside` HOC\n\n\u003e *NOTE*: This is useful if you wish to cause some state change within a component, since\n\u003e the `handleEventOutside` handler is defined within your component.\n\n```js\nimport React, { Component } from 'react'\nimport { withEventOutside } from 'react-detect-event-outside'\n\nclass Handler extends Component {\n  handleEventOutside = (evt, el) =\u003e\n    console.log('Handler: event happened outside', evt, el)\n\n  render() {\n    const { children } = this.props\n    return \u003cdiv className=\"SomeComponent-inside\"\u003e{children}\u003c/div\u003e\n  }\n}\n\nconst WrappedHandler = withEventOutside()(Handler)\n\nconst SomeComponent = () =\u003e (\n  \u003cdiv className=\"SomeComponent\"\u003e\n    \u003cWrappedHandler\u003e\n      \u003ch2\u003eInside\u003c/h2\u003e\n      \u003cinput type=\"text\" /\u003e\n    \u003c/WrappedHandler\u003e\n    \u003cdiv className=\"SomeComponent-outside\"\u003e\n      \u003ch2\u003eOutside\u003c/h2\u003e\n      \u003cinput type=\"text\" /\u003e\n    \u003c/div\u003e\n  \u003c/div\u003e\n)\n\nexport default SomeComponent\n```\n\n## Install\n\n```sh\nyarn add react-detect-event-outside\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsebinsua%2Freact-detect-event-outside","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsebinsua%2Freact-detect-event-outside","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsebinsua%2Freact-detect-event-outside/lists"}