{"id":16594595,"url":"https://github.com/antonybudianto/react-firebase-hoc","last_synced_at":"2026-04-12T19:52:05.313Z","repository":{"id":65372972,"uuid":"88514230","full_name":"antonybudianto/react-firebase-hoc","owner":"antonybudianto","description":"🔥 React Higher Order Components for Firebase","archived":false,"fork":false,"pushed_at":"2017-05-03T14:18:59.000Z","size":9,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-18T09:46:59.235Z","etag":null,"topics":["firebase","hoc","react","react-native","reactjs"],"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/antonybudianto.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-04-17T14:08:43.000Z","updated_at":"2018-09-19T03:45:35.000Z","dependencies_parsed_at":"2023-01-19T23:35:21.497Z","dependency_job_id":null,"html_url":"https://github.com/antonybudianto/react-firebase-hoc","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antonybudianto%2Freact-firebase-hoc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antonybudianto%2Freact-firebase-hoc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antonybudianto%2Freact-firebase-hoc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antonybudianto%2Freact-firebase-hoc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/antonybudianto","download_url":"https://codeload.github.com/antonybudianto/react-firebase-hoc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242251551,"owners_count":20097021,"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":["firebase","hoc","react","react-native","reactjs"],"created_at":"2024-10-11T23:46:45.408Z","updated_at":"2025-12-31T00:59:08.001Z","avatar_url":"https://github.com/antonybudianto.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-firebase-hoc\nReact [Higher Order Components](https://facebook.github.io/react/docs/higher-order-components.html) for Firebase. Compatible with React and React Native.\n\n[![npm version](https://badge.fury.io/js/react-firebase-hoc.svg)](https://badge.fury.io/js/react-firebase-hoc)\n\n\n## Requirements\n- Bundler that supports ES7 Async/await (Both [CRA](https://github.com/facebookincubator/create-react-app) and [CRNA](https://github.com/react-community/create-react-native-app) supported it)\n\n## How to use\n1. Install the package\n   ```sh\n   npm install react-firebase-hoc\n   ```\n\n2. Use them on your component\n   ```js\n   import * as firebase from 'firebase';\n   import { FetchOnce } from 'react-firebase-hoc';\n\n   const firebaseConfig = {...};\n   const firebaseApp = firebase.initializeApp(firebaseConfig);\n\n   /**\n    * later after component declaration...\n    * 1st param is the firebaseApp instance\n    * 2nd param is the namespace for the fetched data\n    * 3rd param is the callback, (db, props, state)\n    */\n   const MyComponentWithData = FetchOnce(firebaseApp, 'users',\n    (db) =\u003e db.ref('users'))(MyComponent)\n\n   // or you can use it as decorator too\n   @FetchOnce(firebaseApp, 'users', (db) =\u003e db.ref('users'))\n   class MyComponent extends React.Component {...}\n   ```\n\n3. You'll get the injected props on your component\n   ```js\n   // users is the namespace specified on the first param of HOC\n   console.log(this.props.users.loading) // true/false\n   console.log(this.props.users.error) // null/object\n   console.log(this.props.users.data) // null/object\n   ```\n\n## Callback parameters\nYou also have access to the props and state on the callback HOC\n\n```js\n@FetchOnce(firebaseApp, 'users', (db, props, state) =\u003e db.ref(`users/${props.userId}`))\n```\n\n## Tips\nYou can re-wrap the HOC if you always use one firebaseApp instance, for example:\n```js\nimport * as firebase from 'firebase';\nimport { FetchOnce as FetchOnceOrig } from 'react-firebase-hoc';\n\nconst firebaseConfig = {...};\nconst firebaseApp = firebase.initializeApp(firebaseConfig);\n\nfunction FetchOnce(propName, callback) {\n  return FetchOnceOrig(firebaseApp, propName, callback);\n}\n```\n\n## License\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantonybudianto%2Freact-firebase-hoc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fantonybudianto%2Freact-firebase-hoc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantonybudianto%2Freact-firebase-hoc/lists"}