Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dbilgili/uselog-hook
🐠 Simple state observer hook for react
https://github.com/dbilgili/uselog-hook
Last synced: 7 days ago
JSON representation
🐠 Simple state observer hook for react
- Host: GitHub
- URL: https://github.com/dbilgili/uselog-hook
- Owner: dbilgili
- License: mit
- Created: 2019-03-18T21:44:57.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-03-22T22:25:11.000Z (over 5 years ago)
- Last Synced: 2024-10-20T04:37:36.007Z (25 days ago)
- Language: JavaScript
- Homepage:
- Size: 27.3 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
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.
![Kapture 2019-03-18 at 22 31 37](https://user-images.githubusercontent.com/22943912/54565133-b8428000-49cd-11e9-964f-bf2b076533f4.gif)
`npm install --save uselog-hook`
## Usage
```javascript
import useLog from 'uselog-hook';
```Assume there are three state variables.
```javascript
const [apple, setApple] = useState(0);
const [orange, setOrange] = useState(0);
const [kiwi, setKiwi] = useState(0);
``````javascript
useLog(apple);> 0
``````javascript
useLog([apple, orange]);> 0
> 0
``````javascript
useLog({apple, orange});> {apple: 0, orange: 0}
``````javascript
useLog({'Num of apples: ': apple});> {'Num of apples': 0}
```