{"id":26319513,"url":"https://github.com/nickbullll/react-fetch-hoc","last_synced_at":"2025-03-15T15:19:38.640Z","repository":{"id":57344660,"uuid":"101506021","full_name":"nickbullll/react-fetch-hoc","owner":"nickbullll","description":"Simple React fetch high order component 🚴🏽","archived":false,"fork":false,"pushed_at":"2017-08-26T21:43:14.000Z","size":22,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-06T03:47:20.659Z","etag":null,"topics":["higher-order-component","react","react-hoc","reactjs","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/nickbullll.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":"2017-08-26T18:46:51.000Z","updated_at":"2020-05-19T03:14:46.000Z","dependencies_parsed_at":"2022-09-11T09:01:56.513Z","dependency_job_id":null,"html_url":"https://github.com/nickbullll/react-fetch-hoc","commit_stats":null,"previous_names":["abraztsov/react-fetch-hoc"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nickbullll%2Freact-fetch-hoc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nickbullll%2Freact-fetch-hoc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nickbullll%2Freact-fetch-hoc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nickbullll%2Freact-fetch-hoc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nickbullll","download_url":"https://codeload.github.com/nickbullll/react-fetch-hoc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243746273,"owners_count":20341212,"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":["higher-order-component","react","react-hoc","reactjs","redux"],"created_at":"2025-03-15T15:19:38.081Z","updated_at":"2025-03-15T15:19:38.632Z","avatar_url":"https://github.com/nickbullll.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"React Fetch HOC\n=================\n[![npm version](https://badge.fury.io/js/react-simple-fetch-hoc.svg)](https://badge.fury.io/js/react-simple-fetch-hoc)\n\nAn experiment to quickly integrate and use an API requests with High Order Component 🚴🏽\n\n#### The API might change any day.\n#### Do not use in Production!\n\nHow to install ?\n-----\n\n`npm i -s react-simple-fetch-hoc`\n\nWhat is it ?\n-----\n\nIt's a simple library build on \u003ca href=\"https://facebook.github.io/react/docs/higher-order-components.html\"\u003eReact High Order Components\u003c/a\u003e and on \u003ca href=\"https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API\"\u003efetch\u003c/a\u003e (currently)\nwhich assumes responsibility for receiving data from the server and transferring it to your component.\n\n### Example\n\n```\nimport React from 'react';\nimport fetch from 'isomorphic-fetch';\nimport fetchHoc from 'react-fetch-hoc';\n\nconst API_ROUTE = 'https://jsonplaceholder.typicode.com/posts';\n\nconst Post = ({ title, body }) =\u003e {\n  return (\n    \u003cdiv\u003e\n      \u003ch3\u003e{title}\u003c/h3\u003e\n      \u003cdiv\u003e{body}\u003c/div\u003e\n    \u003c/div\u003e\n  )\n}\n\nconst withFetchPost = fetchHoc(props =\u003e fetch(`${API_ROUTE}${props.id}`));\nconst PostContainer = withFetchPost(Post);\n\nconst App = ({ id = 1 }) =\u003e \u003cPostContainer id={id} /\u003e\nexport default App;\n\n```\n\nThe API get call to `https://jsonplaceholder.typicode.com/posts/1` will send us response as\n```\n{\n  title: 'Summer',\n  body: 'That summer was so fine that I dec...'\n}\n```\n\nWhat problem does it solve ?\n-----\n\nBasically everyone is familiar with using fetch/axios in the `componentDidMount` method. This solution is not the cleanest of all. The concept built into this library allows us keep our components clean and just re-use them where necessary, changing only the shell.\n\nFAQ ?\n-----\n\n### Feature Requests/Find Bug ?\n\nIf you see the potential in this library let's talk. Search for existing GitHub issues and join the conversation or create new!\n\n### Can I use this in production?\n\nI wouldn't. Many use cases are not be considered yet. If you find some use cases this lib can't handle yet, please file an issue.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnickbullll%2Freact-fetch-hoc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnickbullll%2Freact-fetch-hoc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnickbullll%2Freact-fetch-hoc/lists"}