|
1 | | -# react-log-hook |
| 1 | +<div align="center"> |
| 2 | + <img src="https://badgen.net/npm/v/react-log-hook" alt="NPM Version" /> |
| 3 | + <img src="https://badgen.net/npm/license/react-log-hook" alt="License" /> |
| 4 | + <img src="https://badgen.net/bundlephobia/minzip/react-log-hook" alt="minzipped size"/> |
| 5 | + <img src="https://badgen.net/bundlephobia/dependency-count/react-log-hook" alt="dependency count"/> |
| 6 | + <img src="https://github.com/dolfbarr/react-log-hook/workflows/CI/badge.svg" alt="Build Status" /> |
| 7 | + <img src="https://badgen.net/github/last-commit/dolfbarr/react-log-hook/main" alt="Last Commit" /> |
| 8 | + <br> |
| 9 | + <br> |
| 10 | + <div align="center"><strong>🪵 React Log Hook</strong></div> |
| 11 | + <div align="center"> Lightweight & customizable logging hook for your react components lifecycle</div> |
| 12 | + |
| 13 | + <div align="center"> |
| 14 | + <sub>By <a href="https://twitter.com/dolfbarr">Dolf Barr</a></sub> |
| 15 | + </div> |
| 16 | + <br> |
| 17 | + <br> |
| 18 | + <br> |
| 19 | +</div> |
| 20 | + |
| 21 | +# 🪵 react-log-hook |
2 | 22 | React hook for logging per component lifecycle |
| 23 | + |
| 24 | +## Features |
| 25 | +- 🪶 **Lightweight** — under *500B* gzipped |
| 26 | +- 🗂️ **Typed** — made with TypeScript, ships with types |
| 27 | +- 🥰 **Simple** — don't worry about any changes in your props & state |
| 28 | +- 🔧 **Customizable** — work in progress 😉 |
| 29 | +- 🏎️ **Fast** 🔬 **Tested** 📭 **No dependecies** |
| 30 | + |
| 31 | + |
| 32 | + |
| 33 | +## Install |
| 34 | + |
| 35 | +With npm |
| 36 | + |
| 37 | +```sh |
| 38 | +npm install react-log-hook |
| 39 | +``` |
| 40 | + |
| 41 | +With yarn |
| 42 | + |
| 43 | +```sh |
| 44 | +yarn add react-log-hook |
| 45 | +``` |
| 46 | + |
| 47 | +## Usage |
| 48 | + |
| 49 | +```javascript |
| 50 | +import {useLog} from 'react-log-hook' |
| 51 | + |
| 52 | +const App = () => { |
| 53 | + // Add a logger |
| 54 | + const {log} = useLog() |
| 55 | + |
| 56 | + const [state, setState] = useState(null) |
| 57 | + |
| 58 | + // Log the changes via console in real time! |
| 59 | + log(state) |
| 60 | + |
| 61 | + return null |
| 62 | +} |
| 63 | +``` |
| 64 | + |
| 65 | +## FAQ |
| 66 | + |
| 67 | +Comming Soon! |
| 68 | + |
| 69 | +## Roadmap |
| 70 | + |
| 71 | +- [ ] Add previous state checking |
| 72 | +- [ ] Use object copy to persist in time |
| 73 | +- [ ] Use console groups to handle all the logs |
| 74 | +- [ ] Support SSR & Server components |
| 75 | +- [ ] Polish the looks with component names, function calls, time etc |
| 76 | +- [ ] TBD |
| 77 | + |
| 78 | +## Contributing |
| 79 | + |
| 80 | +- 🌟 Stars & 📥 Pull Requests are welcome for sure! ❤️ |
| 81 | + |
| 82 | +### Development |
| 83 | + |
| 84 | +🪵 **react-log-hook** uses npm & npm scripts in development, the following scipts can be handy: |
| 85 | + |
| 86 | +#### `npm run start:demo` |
| 87 | +> Starts a demo app with enabled hook to check it in real environment |
| 88 | +
|
| 89 | +#### `npm run storybook` |
| 90 | +> Starts storybook with exmaple components to test against |
| 91 | +
|
| 92 | +#### `npm run release:check` |
| 93 | +> Combination of linting, type-checking & tests; runs as precommit hook |
| 94 | +
|
| 95 | +## License |
| 96 | + |
| 97 | +[MIT License](LICENSE) |
0 commit comments