πͺ΅ React Log Hook
Lightweight & customizable logging hook for your react components lifecycle
By Dolf Barr
React hook for logging per component lifecycle
- πͺΆ Lightweight β under 2 kB gzipped
- ποΈ Typed β made with TypeScript, ships with types
- π₯° Simple β don't worry about any changes in your props & state
- π§ Customizable β work in progress π
- π¬ Tested β up to 100% coverage
- ποΈ Fast β native react hooks & optimized
- π No dependecies
With npm
npm install -D react-log-hookWith yarn
yarn add -D react-log-hookimport {useLog} from 'react-log-hook' const App = () => { // Add a logger const {log} = useLog() const [state, setState] = useState(null) // Log the changes via console in real time! log(state) return null }- π Yes, πͺ΅ react-log-hook deep copies the value to make sure it will not be changed in the logs later
- πͺ No, πͺ΅ react-log-hook comes with prebundled types
- β
By default πͺ΅ react-log-hook will run only in
devordevelopmentnode evironments defined byNODE_ENV
- Add previous state checking
- Use object copy to persist in time
- Use console groups to handle all the logs
- Add dev environment support by default
- Polish the looks with component names, function calls, time etc
- Add more customization options
- Test with SSR & Server components
- π Stars & π₯ Pull Requests are welcome for sure! β€οΈ
πͺ΅ react-log-hook uses npm & npm scripts in development, the following scipts can be handy:
Starts a demo app with enabled hook to check it in real environment
Starts storybook with example components to test against
Combination of linting, type-checking & tests; runs as precommit hook
