Naismith / react-click-away-listener

:paw_prints: ~500B React Click Away Listener built with React Hooks

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

~500B React Click Away Listener

npm travis code coverage downloads/month pullrequest firsttimersonly

Installation

yarn add react-click-away-listener
  • It's quite small in size.
  • It's built with TypeScript.
  • It supports both Mouse and Touch Events.

Usage

import ClickAwayListener from 'react-click-away-listener';

const App = () => {
	const handleClickAway = () => {
		console.log('Hey, you can close the Popup now');
	};

	return (
		<div id="app">
			<ClickAwayListener onClickAway={handleClickAway}>
				<div> Some Popup, Nav or anything </div>
			</ClickAwayListener>
			<div id="rest-of-the-app">Don't name a div like that :(</div>
		</div>
	);
};

Examples

LICENSE

MIT

About

:paw_prints: ~500B React Click Away Listener built with React Hooks

License:MIT License


Languages

Language:TypeScript 86.9%Language:JavaScript 13.1%