{"id":19011805,"url":"https://github.com/martynaskadisa/react-use-redux","last_synced_at":"2025-06-11T20:37:37.011Z","repository":{"id":57145214,"uuid":"154900941","full_name":"martynaskadisa/react-use-redux","owner":"martynaskadisa","description":"Alternative Redux bindings with upcoming React hooks","archived":false,"fork":false,"pushed_at":"2019-10-30T22:01:02.000Z","size":145,"stargazers_count":31,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-06-02T07:18:13.030Z","etag":null,"topics":["bindings","hooks","react","react-redux","redux"],"latest_commit_sha":null,"homepage":"","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/martynaskadisa.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":"2018-10-26T22:27:25.000Z","updated_at":"2019-10-30T22:01:04.000Z","dependencies_parsed_at":"2022-09-06T00:02:43.353Z","dependency_job_id":null,"html_url":"https://github.com/martynaskadisa/react-use-redux","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/martynaskadisa/react-use-redux","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martynaskadisa%2Freact-use-redux","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martynaskadisa%2Freact-use-redux/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martynaskadisa%2Freact-use-redux/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martynaskadisa%2Freact-use-redux/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/martynaskadisa","download_url":"https://codeload.github.com/martynaskadisa/react-use-redux/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martynaskadisa%2Freact-use-redux/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259335541,"owners_count":22842493,"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":["bindings","hooks","react","react-redux","redux"],"created_at":"2024-11-08T19:15:48.691Z","updated_at":"2025-06-11T20:37:36.975Z","avatar_url":"https://github.com/martynaskadisa.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-use-redux\n\n# The wait is over, just use official `react-redux` package if you want hooks.\n\nAlternative Redux bindings with [React hooks](http://reactjs.org/hooks). \n\nNote: this is an experimental package. I do not recommend using this in production. You're probably better off using [react-redux](https://github.com/reduxjs/react-redux).\n\nDiscussion of using hooks in `react-redux` repo [here](https://github.com/reduxjs/react-redux/issues/1063)\n\n## Installing\n\n```\nnpm install react-use-redux\n```\n\nor \n\n```\nyarn add react-use-redux\n```\n\n## Examples\n\nUsage is very similar to what `react-redux` provides, except it uses hooks.\n\n\nFirstly let's wrap our app with provider from `react-use-redux`:\n\n```jsx\nimport { StoreContext } from 'react-use-redux';\n\nconst store = configureStore(/* ... */)\n\nconst AppWithStore = () =\u003e (\n  \u003cStoreContext.Provider value={store}\u003e\n    \u003cApp /\u003e\n  \u003c/StoreContext.Provider\u003e\n)\n```\n\nNow that we have that taken care of we can connect our functional components to Redux store:\n\n```jsx\nimport { createUseConnect } from 'react-use-redux'\n\nconst useConnect = createUseConnect((state) =\u003e ({ user: state.user }))\n\nconst Profile = () =\u003e {\n  const { user } = useConnect()\n\n  return (\n    \u003cdiv\u003e\n      \u003cdiv\u003eName: {user.name}\u003c/div\u003e\n      \u003cdiv\u003eSurname: {user.surname}\u003c/div\u003e\n    \u003c/div\u003e\n  )\n}\n```\n\nAnd that's it! Now we can use redux state in our components without hocs or render props.\n\n## API\n\n### `StoreContext`\n\nReact context which has two properties: `Provider` and `Consumer`. Value provided to `\u003cStoreContext.Provider /\u003e` should be an instance of Redux store. Use this as a top level wrapper of your app.\n\n### `createUseConnect([mapStateToProps], [mapDispatchToProps], [mergeProps])`\n\nHook creator which returns `useConnect` hook to be used inside a component. Behaviour is almost identical to `connect` from `react-redux`. `useConnect` returns an object of props.\n\n#### `mapStateToProps((state, ownProps) =\u003e object)`\n\nCalled everytime when store is updated. Used to calculate props from current state.\n\n#### `mapDispatchToProps((dispatch, ownProps) =\u003e object)`\n\nUsed to wrap dispatch over provided functions. If `mapDispatchToProps` is not provided, it will fallback to returning `dispatch` to props.\n\n#### `mergeProps((stateProps, dispatchProps, ownProps) =\u003e object)`\n\nUsed to tweak how props should be merged, this is an advanced property. When this function is not provided left-to-right merge is applied:\n```js\n(stateProps, dispatchProps, ownProps) =\u003e ({ ...stateProps, ...dispatchProps, ...ownProps })\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmartynaskadisa%2Freact-use-redux","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmartynaskadisa%2Freact-use-redux","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmartynaskadisa%2Freact-use-redux/lists"}