{"id":18799294,"url":"https://github.com/zaelot-inc/use-reducer-logger","last_synced_at":"2025-06-20T23:09:43.140Z","repository":{"id":48287178,"uuid":"171585965","full_name":"Zaelot-Inc/use-reducer-logger","owner":"Zaelot-Inc","description":"A very basic logger for the useReducer function in the React Hooks API.","archived":false,"fork":false,"pushed_at":"2021-10-16T19:44:56.000Z","size":42,"stargazers_count":94,"open_issues_count":2,"forks_count":16,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-06-20T23:09:00.411Z","etag":null,"topics":["logger","logger-middleware","logging","logging-library","react","react-hooks-api","reacthooks","reactjs","reducer-logger"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/use-reducer-logger","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Zaelot-Inc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-02-20T02:25:59.000Z","updated_at":"2024-10-17T14:13:57.000Z","dependencies_parsed_at":"2022-09-10T00:10:10.249Z","dependency_job_id":null,"html_url":"https://github.com/Zaelot-Inc/use-reducer-logger","commit_stats":null,"previous_names":["jefflombard/simple-react-hook-flux-logger"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/Zaelot-Inc/use-reducer-logger","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zaelot-Inc%2Fuse-reducer-logger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zaelot-Inc%2Fuse-reducer-logger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zaelot-Inc%2Fuse-reducer-logger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zaelot-Inc%2Fuse-reducer-logger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Zaelot-Inc","download_url":"https://codeload.github.com/Zaelot-Inc/use-reducer-logger/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zaelot-Inc%2Fuse-reducer-logger/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261032114,"owners_count":23100051,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["logger","logger-middleware","logging","logging-library","react","react-hooks-api","reacthooks","reactjs","reducer-logger"],"created_at":"2024-11-07T22:14:41.108Z","updated_at":"2025-06-20T23:09:38.126Z","avatar_url":"https://github.com/Zaelot-Inc.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# use-reducer-logger\nA very very basic logger for the `useReducer` function in the [React Hooks API](https://reactjs.org/docs/hooks-reference.html#usereducer). Inspired by [redux-logger](https://github.com/LogRocket/redux-logger).\n\n![screenshot of logger](screenshot.png)\n\n# Usage\n1. Install with `npm install use-reducer-logger --save-dev` or `yarn add use-reducer-logger -D`\n2. Import logger with\n\n```javascript\nimport logger from 'use-reducer-logger';\n```\n\n3. Wrap your reducer with logger before passing it to `useReducer`\n\n```javascript\nconst [state, dispatch] = useReducer(logger(reducer), initialState);\n```\n\nSee [Example](https://github.com/jefflombard/use-reducer-logger-example)\n\n## In a Dev Environment\nYou should only use this in a `dev` environment. So you could do something like this to apply the logger based on the `env`.\n\n```javascript\nfunction reducer(state, action) {\n  switch (action.type) {\n    case 'increment':\n      return {count: state.count + 1};\n    case 'decrement':\n      return {count: state.count - 1};\n    default:\n      throw new Error();\n  }\n}\n\nconst [state, dispatch] = useReducer(\n  process.env.NODE_ENV === 'development' ? logger(reducer) : reducer,\n  initialState\n);\n```\n\n# License\nMIT see [`LICENSE`](/LICENSE).\n\n# Contributing\nContributions are welcome.\n\n# Sponsor\nThis repo is now sponsored/maintained by [Zaelot Inc.](https://zaelot.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzaelot-inc%2Fuse-reducer-logger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzaelot-inc%2Fuse-reducer-logger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzaelot-inc%2Fuse-reducer-logger/lists"}