uselog-hook
v1.1.0
Published
Simple state observer hook for react
Downloads
3
Maintainers
Readme
This tiny development hook for react saves you some time when you just want to observe a single state variable or multiple state variables at the same time.
npm install --save uselog-hook
Usage
import useLog from 'uselog-hook';
Assume there are three state variables.
const [apple, setApple] = useState(0);
const [orange, setOrange] = useState(0);
const [kiwi, setKiwi] = useState(0);
useLog(apple);
> 0
useLog([apple, orange]);
> 0
> 0
useLog({apple, orange});
> {apple: 0, orange: 0}
useLog({'Num of apples: ': apple});
> {'Num of apples': 0}