{"id":23897598,"url":"https://github.com/boostup/react-context-api-multiple-reducers-mulitple-sagas","last_synced_at":"2025-04-15T07:48:02.631Z","repository":{"id":56408941,"uuid":"310888729","full_name":"boostup/react-context-api-multiple-reducers-mulitple-sagas","owner":"boostup","description":"The Flux architectural pattern using useReducer, the Context API, and Sagas","archived":false,"fork":false,"pushed_at":"2020-11-10T13:23:54.000Z","size":403,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T17:57:33.893Z","etag":null,"topics":["context-api","react","redux-saga","usereducer-hooks"],"latest_commit_sha":null,"homepage":"https://confident-turing-f05f43.netlify.app/","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/boostup.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":"2020-11-07T16:43:45.000Z","updated_at":"2024-06-05T04:16:50.000Z","dependencies_parsed_at":"2022-08-15T18:10:35.047Z","dependency_job_id":null,"html_url":"https://github.com/boostup/react-context-api-multiple-reducers-mulitple-sagas","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boostup%2Freact-context-api-multiple-reducers-mulitple-sagas","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boostup%2Freact-context-api-multiple-reducers-mulitple-sagas/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boostup%2Freact-context-api-multiple-reducers-mulitple-sagas/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boostup%2Freact-context-api-multiple-reducers-mulitple-sagas/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/boostup","download_url":"https://codeload.github.com/boostup/react-context-api-multiple-reducers-mulitple-sagas/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249031753,"owners_count":21201356,"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":["context-api","react","redux-saga","usereducer-hooks"],"created_at":"2025-01-04T17:16:47.313Z","updated_at":"2025-04-15T07:48:02.610Z","avatar_url":"https://github.com/boostup.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# The Flux architectural pattern using `useReducer`, the `Context` API, and Sagas\n\nJust in case, here is a nice diagram about the generic Flux pattern in React.\n\n\u003cimg src=\"public/images/flux-pattern.png\" alt=\"Flux architectural pattern\"\u003e\n\n## So, why does this repo even exist?\n\nIt demonstrates the combination of :\n\n- `Context` API and `useContext` hook\n- `useReducer` hook\n- [`useReactSaga` custom hook](https://www.npmjs.com/package/use-react-saga)\n\n---\n\n[Demo Link](https://confident-turing-f05f43.netlify.app/) | [GitHub Repo](https://github.com/boostup/react-context-api-multiple-reducers-mulitple-sagas) | Blog Post on [Dev.to](https://dev.to/boostup/the-flux-architectural-pattern-using-usereducer-the-context-api-and-sagas-8ie)\n\n---\n\n## But why, you ask ?\n\nBecause I can ;)\n\nNo, but seriously, because I needed to make sense of Redux, of the Context API, and more generally, the Flux Pattern, and of async actions.\n\nAlso, to me, it is important to understand as many React functions or third-party packages as I include in my apps, and `useContext` and `useReducer` being shipped defacto with React is a plus, versus having to include a whole bunch of packages that revolve around the Redux ecosystem.\n\nSo this demo allows to demonstrate that the `redux` and `react-redux` packages are no longer required dependencies to implement the Flux Pattern in React, in a way that makes both sense and is scalable with combined reducers to handle endless future slices of state.\n\n## Word of caution\n\nWhat this demo does not demonstrate though, is if this combination mimicking redux will be as performant as redux.\nAnd this, I do not know myself, as this is very experimental. I wouldn't recommend using this in production ;).\n\n## Notes\n\nThis demo depends on a tiny package called `use-react-saga`.\n\nAll it is, is a custom hook for React which depends on the `redux-saga` package, which is something I wanted to experiment with as the next natural evolution step after `redux-thunk`, for async actions.\n\n## Addendum\n\nAfter the perusal of the installed packages in the `node_modules` directory, I have come to realize that there is a `redux` directory in there!! After perusing the `yarn.lock` file, `redux-saga` packages has it as a dependency.\n\nSo this demo does NOT unfortunately demonstrate that adding Redux as a dependency can be avoided. Fortunately, it is only [2kB, including dependencies](https://www.npmjs.com/package/redux)!\n\nSo this demo only goes to shows how **unavoidable** `redux` is when it comes to making stable apps ;)\n\nIn the particular case of this demo, if I wish to remove it as a dependency, I must implement Sagas myself. Is it worth it ? I'll leave it up to you to decide.\n\nFinally, I should mention that I do not hold a grudge against Redux, I just wanted to evaluate the Context API as a potential replacement, since we see so many articles on this topic, but they all show very small unscalable demos or POCs which were never convincing to me.\n\n---\n\n# Getting Started with Create React App\n\nThis project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).\n\n## Available Scripts\n\nIn the project directory, you can run:\n\n### `yarn start`\n\nRuns the app in the development mode.\\\nOpen [http://localhost:3000](http://localhost:3000) to view it in the browser.\n\nThe page will reload if you make edits.\\\nYou will also see any lint errors in the console.\n\n### `yarn test`\n\nLaunches the test runner in the interactive watch mode.\\\nSee the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.\n\n### `yarn build`\n\nBuilds the app for production to the `build` folder.\\\nIt correctly bundles React in production mode and optimizes the build for the best performance.\n\nThe build is minified and the filenames include the hashes.\\\nYour app is ready to be deployed!\n\nSee the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.\n\n### `yarn eject`\n\n**Note: this is a one-way operation. Once you `eject`, you can’t go back!**\n\nIf you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.\n\nInstead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.\n\nYou don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.\n\n## Learn More\n\nYou can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).\n\nTo learn React, check out the [React documentation](https://reactjs.org/).\n\n### Code Splitting\n\nThis section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)\n\n### Analyzing the Bundle Size\n\nThis section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)\n\n### Making a Progressive Web App\n\nThis section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)\n\n### Advanced Configuration\n\nThis section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)\n\n### Deployment\n\nThis section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)\n\n### `yarn build` fails to minify\n\nThis section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fboostup%2Freact-context-api-multiple-reducers-mulitple-sagas","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fboostup%2Freact-context-api-multiple-reducers-mulitple-sagas","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fboostup%2Freact-context-api-multiple-reducers-mulitple-sagas/lists"}