react-clap
v0.0.1
Published
Simple clap component similar to one found on medium.com
Downloads
10
Readme
react-clap
Simple clap component for react mimicking the behaviour of clap button on medium.com
.
Installation
npm install react-clap
Usage
import CardTree from 'react-clap';
Render it as show below
<ClapComponent
popupClapCount={this.state.clapsCount}
maxClapCount={50}
onChange={(newClapCount, diff) => {
this.setState({
clapsCount: newClapCount,
totalClapCount: this.state.totalClapCount + diff,
});
}}
/>
Props
popupClapCount
: (Required)The clap count to be used by the component. You can set it to any number. Make sure to update the component with new clap counton change
. Default: nonemaxClapCount
: (Optional)Max Clap count that the component can accumulate. Default: 50onChange(newClapCount, diff)
: Function that will be called whenclap
stops.newClapCount
will be the clap count accumulated by the component.diff
is the value of difference between theproperty
popupClapCount
and the componentspopupClapCount
. Note:diff
would show wrong value when you don't send the new property on change. In the above example's onChange, the clapcount is updated in state and sent as prop to the component.
Credits:
- “Clap” icon by Yamini Ahluwalia from the Noun Project.
- mo.js