npm.io
1.0.5 • Published 5 years ago

use-strict-click-handler

Licence
MIT
Version
1.0.5
Deps
0
Size
556 kB
Vulns
0
Weekly
0
Stars
2

use-strict-click-handler

NPM

Install

npm install --save use-strict-click-handler

Usage

import * as React from 'react';
import useStrictClickHandler from 'use-strict-click-handler';

const Example = () => {
  const { handlers } = useStrictClickHandler(() =>
    console.log('STRICT CLICKED!')
  );
  return (
    <>
      <div className="App" {...handlers}>
        <h1>STRICT CLICK</h1>
        <ol>
          <li>Open console.</li>
          <li>Click or drag inside this component.</li>
          <li>Drag events are excluded.</li>
        </ol>
      </div>
      <div className="App" onClick={() => console.log('NORMAL CLICKED!')}>
        <h1>NORMAL CLICK</h1>
        <ol>
          <li>Open console.</li>
          <li>Click or drag inside this component.</li>
          <li>Drag events are included.</li>
        </ol>
      </div>
    </>
  );
};

Demo

https://odd-aunt.surge.sh/

License

MIT ossan-engineer


This hook is created using create-react-hook.