Skip to content

Latest commit

 

History

History
41 lines (31 loc) · 906 Bytes

File metadata and controls

41 lines (31 loc) · 906 Bytes

Active

The Active component is used to known when user is clicking (holding) some element.
It's the same as :active pseudo selector from css.

import { Active } from 'react-powerplug'
<Active>
  {({ active, bind }) => (
    <div {...bind}>
      You are {active ? 'clicking' : 'not clicking'} this div.
    </div>
  )}
</Active>

Active Props

onChange (optional)
The onChange event of the Active is called whenever the active state changes.

Active Children Props

TL;DR: { active, bind }

active
boolean
True if is activated (being clicked) the binded element

bind
{ onMouseUp: () => void, onMouseDown: () => void }
There are the bind event functions that make Active works.
You must bind some element to track their events.
You can use spread operator to bind effectively an element.

<span {...bind}>Binded!</span>