{"id":29023000,"url":"https://github.com/bamlab/react-redux-toolbox","last_synced_at":"2025-06-26T03:04:56.802Z","repository":{"id":57343393,"uuid":"98227634","full_name":"bamlab/react-redux-toolbox","owner":"bamlab","description":"Set of utils for React and Redux development","archived":false,"fork":false,"pushed_at":"2017-09-13T07:38:09.000Z","size":16,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-06-12T21:12:15.339Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bamlab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-07-24T19:34:46.000Z","updated_at":"2018-10-18T17:11:45.000Z","dependencies_parsed_at":"2022-09-12T07:00:21.369Z","dependency_job_id":null,"html_url":"https://github.com/bamlab/react-redux-toolbox","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/bamlab/react-redux-toolbox","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bamlab%2Freact-redux-toolbox","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bamlab%2Freact-redux-toolbox/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bamlab%2Freact-redux-toolbox/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bamlab%2Freact-redux-toolbox/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bamlab","download_url":"https://codeload.github.com/bamlab/react-redux-toolbox/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bamlab%2Freact-redux-toolbox/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261990349,"owners_count":23241188,"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":"2025-06-26T03:04:55.081Z","updated_at":"2025-06-26T03:04:56.783Z","avatar_url":"https://github.com/bamlab.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# React Redux Utils\n\n## Redux\n\n### API Loaders\n\n#### Saga Decorator\n\n`react-redux-toolbox` exposes a decorator to wrap your saga between two action dispatched.\n\n```javascript\nimport { addLoader } from 'react-redux-toolbox';\n\nexport function* watchFetchMovies(): SagaType {\n  yield takeLatest(actionTypes.FETCH_MOVIES, addLoader(fetchMovies, 'movies'));\n}\n```\n\nIn the example above,\n```javascript\n{\n  type: 'react-redux-toolbox/SHOW_LOADER',\n  loaderName: 'movies',\n}\n```\nwill be dispatched before the action, and\n```javascript\n{\n  type: 'react-redux-toolbox/SHOW_LOADER',\n  loaderName: 'movies',\n}\n```\njust after.\n\n#### Loader reducer\n\n`react-redux-toolbox` also provides a reducer that you can add to your store, which will to the actions dipatched by the Saga Decorator to update your store:\n\n```javascript\nimport { combineReducers } from 'redux';\nimport { loaderReducer } from 'react-redux-toolbox';\n\nconst rootReducer = combineReducers({\n  loader: loaderReducer,\n  ...\n});\n```\n\n**A selector** is also included:\n```javascript\nexport const isLoading = (state: any, loaderName: string, reducerName = 'loader'): boolean\n```\n\n#### Automatically change your components into Loaders\n\nWhen using the saga decorator, with the `loader` reducer added to your store, wrap your components inside a `LoaderWrapper` and a loader will be displayed in their place when the `loaderName` is marked as loading.\n\n```javascript\nimport { LoaderWrapper } from 'react-redux-toolbox';\n\n...\n\nrender() {\n  return (\n    \u003cLoaderWrapper loaderName=\"movies\"\u003e\n      \u003cMovies\u003e\n    \u003c/LoaderWrapper\u003e\n  )\n}\n```\n\n### Error handling\n\n`react-redux-toolbox` exposes a decorator to automatically handle common API errors. For instance:\n\n```javascript\nimport { addLoader, catchApiExceptions as catchApiExceptionsUtil } from 'react-redux-toolbox';\n\nconst handleApiException = (error: any) =\u003e {\n  if (__DEV__) console.warn(error);\n\n  if (!error.response) {\n    Toast.show('Connection error');\n    return;\n  }\n\n  Toast.show('Something bad happened');\n};\n\nconst catchApiExceptions = (saga, timeout) =\u003e catchApiExceptionsUtil(saga, timeout, handleApiException);\n\nexport function* watchFetchMovies(): SagaType {\n  yield takeLatest(actionTypes.FETCH_MOVIES, addLoader(\n    catchApiExceptions(fetchMovies),\n    'movies'\n  ));\n}\n```\n\n## Debug\n\n### Setup React Native debugger\n\nRedirect network calls to the react native debugger:\n```javascript\nimport 'react-redux-toolbox/debug/setupReactNativeDebugger';\n```\n\n## Testing\n\n### `getNodeText`\n\n```javascript\nimport React from 'react';\nimport { Text, View } from 'react-native';\nimport { shallow } from 'enzyme';\nimport { getNodeText } from 'react-redux-toolbox';\n\ndescribe('getNodeText', () =\u003e {\n  it('returns the sum of the two nodes text', () =\u003e {\n    const component = shallow(\u003cView\u003e\n      \u003cText\u003efirst text\u003c/Text\u003e\n      \u003cText\u003esecond text\u003c/Text\u003e\n    \u003c/View\u003e);\n\n    expect(getNodeText(component)).toEqual('first textsecond text');\n  });\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbamlab%2Freact-redux-toolbox","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbamlab%2Freact-redux-toolbox","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbamlab%2Freact-redux-toolbox/lists"}