react-use-duplex
v0.1.0
Published
React hook for duplex buttons state
Downloads
5
Readme
react-use-duplex
React hook for duplex buttons state
Note: This is using the new React Hooks API Proposal which is subject to change until React 16.7 final.
You'll need to install
react
,react-dom
, etc at^16.7.0-alpha.0
Install
npm i react-use-duplex
Usage
import useDuplex from 'react-use-duplex';
const MyComponent = () => {
const { state, handleLeft, handleRight } = useDuplex({
initialState: 'left', // optional
});
return (
<div>
<button onClick={handleLeft}>
{state === 'left' ? 'Approved 👍' : 'Approve'}
</button>
<button onClick={handleRight}>
{state === 'right' ? 'Rejected 👎' : 'Reject'}
</button>
</div>
);
};