{"id":19643227,"url":"https://github.com/sorenlouv/react-redux-request","last_synced_at":"2025-10-25T05:46:45.044Z","repository":{"id":57343318,"uuid":"132380786","full_name":"sorenlouv/react-redux-request","owner":"sorenlouv","description":"Declarative data fetching for React, stored in Redux.","archived":false,"fork":false,"pushed_at":"2018-07-26T13:49:44.000Z","size":391,"stargazers_count":4,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-05T09:11:27.802Z","etag":null,"topics":["api","declarative","fetch","http","react","react-redux","redux","request","rest"],"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/sorenlouv.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-05-06T22:27:04.000Z","updated_at":"2018-10-30T13:56:32.000Z","dependencies_parsed_at":"2022-09-12T07:00:19.251Z","dependency_job_id":null,"html_url":"https://github.com/sorenlouv/react-redux-request","commit_stats":null,"previous_names":["sorenlouv/react-redux-request","sqren/react-redux-request"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sorenlouv%2Freact-redux-request","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sorenlouv%2Freact-redux-request/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sorenlouv%2Freact-redux-request/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sorenlouv%2Freact-redux-request/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sorenlouv","download_url":"https://codeload.github.com/sorenlouv/react-redux-request/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251319747,"owners_count":21570450,"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":["api","declarative","fetch","http","react","react-redux","redux","request","rest"],"created_at":"2024-11-11T14:19:41.480Z","updated_at":"2025-10-25T05:46:39.998Z","avatar_url":"https://github.com/sorenlouv.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/sqren/react-redux-request.svg?branch=master)](https://travis-ci.org/sqren/react-redux-request)\n[![NPM version](https://img.shields.io/npm/v/react-redux-request.svg)](https://www.npmjs.com/package/react-redux-request)\n[![dependencies Status](https://david-dm.org/sqren/react-redux-request/status.svg)](https://david-dm.org/sqren/react-redux-request)\n\nRedux is great for handling application state but requires a lot of generic boilerplate when it comes to data fetching: action creators, reducers, thunks/sagas and connected, stateful components.\n`react-redux-request` is a simple component that will fetch data, store it in Redux, and render it via a render prop.\n\n**Advantages over similar approaches:**\n\n* Integrates seamlessly with Redux\n* BYOD (Bring-Your-Own-Datafetcher): no assumptions are made about how you fetch data. Just supply an async function, and the `react-redux-request` will call it and handle the resolve/rejected values.\n* Uses render props rather than higher-order-components (HOC)\n\n[Demo on Codesandbox](https://codesandbox.io/s/64l7r47myn)\n\n### Install\n\n```\nyarn add react-redux-request\n```\n\n### Getting started\n\n```js\nimport { createStore, combineReducers } from 'redux';\nimport { Provider } from 'react-redux';\nimport { Request, reducer } from 'react-redux-request';\n\n// Add reducer to your store\nconst reducers = combineReducers({ reactReduxRequest: reducer });\nconst store = createStore(reducers);\n\n// `getData` must return a promise\nfunction getData() {\n  return fetch(`https://jsonplaceholder.typicode.com/posts/1`).then(response =\u003e\n    response.json()\n  );\n}\n\nconst App = () =\u003e (\n  \u003cProvider store={store}\u003e\n    \u003cRequest\n      fn={getData}\n      id=\"post\"\n      render={({ status, data, error }) =\u003e \u003cdiv\u003e{status}\u003c/div\u003e}\n    /\u003e\n  \u003c/Provider\u003e\n);\n```\n\n### Run examples locally\n\n```\nnpm start\n```\n\nOpen [localhost:6006](http://localhost:6006) in your browser\n\nAll examples are located in [https://github.com/sqren/react-redux-request/tree/master/stories](stories/)\n\n### API\n\n#### args: array\n\nA list of arguments that will be applied to `fn`.\n\nExample: `['a', 'b']`\n\n#### fn: func\n\nA function to fetch data. This must return a promise that resolves with the response. Arguments can be supplied with `args` prop. This will only be invoked on initial mount, and when `args` change.\n\n#### id: string\n\nThe identifier used to store the data in redux. If `id` is `selected-user`, the data will be stored in `store.reactReduxRequest['selected-user']`.\nThis is useful if you have data you want to display different places in your application. By relying on redux as a cache, `reactReduxRequest` will only fetch the data once.\n\n#### render: func\n\nA so-called [render-prop](https://reactjs.org/docs/render-props.html) that will be called with the resolved or rejected value of `fn`. The render function is called with an object with these keys `{status, data, error}`\n\n#### selector: func\n\nThis takes a selector (eg. from [re-select](https://github.com/reduxjs/reselect)) that will be called with `state, { id }`, where `state` is the entire store state, and `id` is the identifier supplied to the `Request` component.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsorenlouv%2Freact-redux-request","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsorenlouv%2Freact-redux-request","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsorenlouv%2Freact-redux-request/lists"}