{"id":13452446,"url":"https://github.com/troch/reinspect","last_synced_at":"2025-05-16T13:02:46.527Z","repository":{"id":33658596,"uuid":"160402925","full_name":"troch/reinspect","owner":"troch","description":"Use redux devtools to inspect useState and useReducer :mag_right:","archived":false,"fork":false,"pushed_at":"2023-08-20T11:38:34.000Z","size":2838,"stargazers_count":425,"open_issues_count":54,"forks_count":24,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-09T08:03:09.099Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/troch.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-12-04T18:41:34.000Z","updated_at":"2025-03-01T16:58:44.000Z","dependencies_parsed_at":"2024-01-06T07:59:26.603Z","dependency_job_id":"e342bfbd-a3ab-4445-93d6-0a5cdc62b25e","html_url":"https://github.com/troch/reinspect","commit_stats":{"total_commits":45,"total_committers":6,"mean_commits":7.5,"dds":0.3111111111111111,"last_synced_commit":"4d0b4160afe6f51596b984ba9fde737d609ddedd"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/troch%2Freinspect","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/troch%2Freinspect/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/troch%2Freinspect/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/troch%2Freinspect/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/troch","download_url":"https://codeload.github.com/troch/reinspect/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254535792,"owners_count":22087397,"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":[],"created_at":"2024-07-31T07:01:24.365Z","updated_at":"2025-05-16T13:02:46.510Z","avatar_url":"https://github.com/troch.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# reinspect\n\n\u003e Under development\n\nConnect React state hooks (`useState` and `useReducer`) to redux dev tools.\n\n[See it live](https://7ypv9qw6j0.codesandbox.io/)\n\n![useState with Redux dev tools](https://user-images.githubusercontent.com/1777517/49508706-4b223900-f87b-11e8-9c64-534e3dc51047.gif)\n\n## Why?\n\nHooks are great, they are a joy to use to create state in components. On the other hand, with something global and centralised like Redux, we have [great dev tools](https://github.com/zalmoxisus/redux-devtools-extension).\n\nWhy not both? That's exactly what this package offers: connecting `useState` and `useReducer` to redux dev tools, so you can do the following:\n\n-   Inspect actions and state for each hook\n-   Time travel through state changes in your app\n-   Hot reloading: save your current state and re-inject it when re-rendering\n\n## API\n\nYou need [redux devtools](https://github.com/zalmoxisus/redux-devtools-extension) installed. This package provides:\n\n-   `StateInspector`: a provider which will be used by `useState` and `useReducer` to connect them to a store and redux dev tools.\n\n    -   It accepts optionally a `name` (name of the store in dev tools) and `initialState` (if you want to start with a given state)\n    -   You can have more than one `StateInspector` in your application, hooks will report to the nearest one\n    -   Without a `StateInspector`, `useState` and `useReducer` behave normally\n\n    ```js\n    import React from \"react\"\n    import { StateInspector } from \"reinspect\"\n    import App from \"./App\"\n\n    function AppWrapper() {\n        return (\n            \u003cStateInspector name=\"App\"\u003e\n                \u003cApp /\u003e\n            \u003c/StateInspector\u003e\n        )\n    }\n\n    export default AppWrapper\n    ```\n\n-   `useState(initialState, id?)`: like [useState](https://reactjs.org/docs/hooks-reference.html#usestate) but with a 2nd argument `id` (a unique ID to identify it in dev tools). If no `id` is supplied, the hook won't be connected to dev tools.\n\n    ```js\n    import React from \"react\"\n    import { useState } from \"reinspect\"\n\n    export function CounterWithUseState({ id }) {\n        const [count, setCount] = useState(0, id)\n\n        return (\n            \u003cdiv\u003e\n                \u003cbutton onClick={() =\u003e setCount(count - 1)}\u003e-\u003c/button\u003e\n                {count} \u003cbutton onClick={() =\u003e setCount(count + 1)}\u003e+\u003c/button\u003e\n            \u003c/div\u003e\n        )\n    }\n    ```\n\n-   `useReducer(reducer, initialState, initializer?, id?)`: like [useReducer](https://reactjs.org/docs/hooks-reference.html#usereducer) but with a 4th argument `id` (a unique ID to identify it in dev tools). If no `id` is supplied, the hook won't be connected to dev tools. You can use identity function (`state =\u003e state`) as 3rd parameter to mock lazy initialization.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftroch%2Freinspect","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftroch%2Freinspect","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftroch%2Freinspect/lists"}