{"id":14384864,"url":"https://github.com/unfold/react-firebase","last_synced_at":"2025-04-06T11:10:41.265Z","repository":{"id":56275308,"uuid":"54538388","full_name":"unfold/react-firebase","owner":"unfold","description":"React bindings for Firebase","archived":false,"fork":false,"pushed_at":"2020-11-17T09:42:56.000Z","size":178,"stargazers_count":106,"open_issues_count":6,"forks_count":22,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-30T09:09:40.100Z","etag":null,"topics":["firebase","higher-order-component","react","react-bindings"],"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/unfold.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":"2016-03-23T07:06:50.000Z","updated_at":"2022-01-26T01:12:53.000Z","dependencies_parsed_at":"2022-08-15T15:50:37.540Z","dependency_job_id":null,"html_url":"https://github.com/unfold/react-firebase","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unfold%2Freact-firebase","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unfold%2Freact-firebase/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unfold%2Freact-firebase/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unfold%2Freact-firebase/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/unfold","download_url":"https://codeload.github.com/unfold/react-firebase/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247471521,"owners_count":20944158,"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","higher-order-component","react","react-bindings"],"created_at":"2024-08-28T18:01:43.891Z","updated_at":"2025-04-06T11:10:41.231Z","avatar_url":"https://github.com/unfold.png","language":"JavaScript","readme":"React Firebase\n==============\n\nReact bindings for [Firebase](https://firebase.google.com).\n\n\n__:warning: React Firebase in not maintained anymore__\n\u003e There might come a replacement from [React itself](\nhttps://github.com/unfold/react-firebase/issues/57#issuecomment-644762819) with Suspense, but when is not certain. If you want to contribute or maintain this project, send a message to @einarlove.\n\n## Installation\n\n```\nnpm install --save react-firebase\n```\n\nReact Firebase requires **[React 0.14](https://github.com/facebook/react) and [Firebase 3](https://www.npmjs.com/package/firebase) or later.**\n\n## Example\n\n```js\nimport React from 'react'\nimport firebase from 'firebase'\nimport { connect } from 'react-firebase'\n\nfirebase.initializeApp({\n  databaseURL: 'https://react-firebase-sandbox.firebaseio.com'\n})\n\nconst Counter = ({ value, setValue }) =\u003e (\n  \u003cdiv\u003e\n    \u003cbutton onClick={() =\u003e setValue(value - 1)}\u003e-\u003c/button\u003e\n    \u003cspan\u003e{value}\u003c/span\u003e\n    \u003cbutton onClick={() =\u003e setValue(value + 1)}\u003e+\u003c/button\u003e\n  \u003c/div\u003e\n)\n\nexport default connect((props, ref) =\u003e ({\n  value: 'counterValue',\n  setValue: value =\u003e ref('counterValue').set(value)\n}))(Counter)\n```\n\n## Test for yourself on Codepen.io\n- [Get started template](https://codepen.io/einarlove/pen/peoMbp?editors=1010)\n- [Counter example](https://codepen.io/einarlove/pen/RpwXGP?editors=1010)\n\n## Usage\n\n### `connect([mapFirebaseToProps], [mergeProps])`\n\nConnects a React component to a Firebase App reference.\n\nIt does not modify the component class passed to it. Instead, it *returns* a new, connected component class, for you to use.\n\n#### Arguments\n\n* [`mapFirebaseToProps(props, ref, firebaseApp): subscriptions`] \\(*Object or Function*): Its result, or the argument itself must be a plain object. Each value must either be a path to a location in your database, a query object or a function. If you omit it, the default implementation just passes `firebaseApp` as a prop to your component.\n\n\n* [`mergeProps(ownProps, firebaseProps): props`] \\(*Function*): If specified, it is passed the parent `props` and current subscription state merged with the result of `mapFirebaseToProps()`. The plain object you return from it will be passed as props to the wrapped component. If you omit it, `Object.assign({}, ownProps, firebaseProps)` is used by default.\n\n#### Returns\n\nA React component class that passes subscriptions and actions as props to your component according to the specified options.\n\n\u003e Note: \"actions\" are any function values returned by `mapFirebaseToProps()` which are typically used to modify data in Firebase.\n\n##### Static Properties\n\n* `WrappedComponent` *(Component)*: The original component class passed to `connect()`.\n\n##### Pass `todos` as a prop\n\n  \u003e Note: The value of `todos` is the path to your data in Firebase. This is equivalent to `firebase.database().ref('todo')`.\n\n```js\nconst mapFirebaseToProps = {\n  todos: 'todos'\n}\n\nexport default connect(mapFirebaseToProps)(TodoApp)\n```\n\n#####  Pass `todos` and a function that adds a new todo (`addTodo`) as props\n\n```js\nconst mapFirebaseToProps = (props, ref) =\u003e ({\n  todos: 'todos',\n  addTodo: todo =\u003e ref('todos').push(todo)\n})\n\nexport default connect(mapFirebaseToProps)(TodoApp)\n```\n\n#####  Pass `todos`, `completedTodos`, a function that completes a todo (`completeTodo`) and one that logs in as props\n\n```js\nconst mapFirebaseToProps = (props, ref, firebase) =\u003e ({\n  todos: 'todos',\n  completedTodos: {\n    path: 'todos',\n    orderByChild: 'completed',\n    equalTo: true\n  },\n  completeTodo = id =\u003e ref(`todos/${id}/completed`).set(true),\n  login: (email, password) =\u003e firebase.auth().signInWithEmailAndPassword(email, password)\n})\n\nexport default connect(mapFirebaseToProps)(TodoApp)\n```\n\n### `\u003cProvider firebaseApp\u003e`\n\nBy default `connect()` will use the [default Firebase App](https://firebase.google.com/docs/reference/js/firebase.app). If you have multiple Firebase App references in your application you may use this to specify the Firebase App reference available to `connect()` calls in the component hierarchy below.\n\nIf you *really* need to, you can manually pass `firebaseApp` as a prop to every `connect()`ed component, but we only recommend to do this for stubbing `firebaseApp` in unit tests, or in non-fully-React codebases. Normally, you should just use `\u003cProvider\u003e`.\n\n#### Props\n\n* `firebaseApp` (*[App](https://firebase.google.com/docs/reference/js/firebase.app.App)*): A Firebase App reference.\n* `children` (*ReactElement*): The root of your component hierarchy.\n\n#### Example\n\n```js\nimport { Provider } from 'react-firebase'\nimport { initializeApp } from 'firebase'\n\nconst firebaseApp = initializeApp({\n  databaseURL: 'https://my-firebase.firebaseio.com'\n})\n\nReactDOM.render(\n  \u003cProvider firebaseApp={firebaseApp}\u003e\n    \u003cMyRootComponent /\u003e\n  \u003c/Provider\u003e,\n  rootEl\n)\n```\n\n## License\n\nMIT\n\n## Acknowledgements\n\n[`react-redux`](https://github.com/reactjs/react-redux) which this library is heavily inspired by.\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funfold%2Freact-firebase","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Funfold%2Freact-firebase","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funfold%2Freact-firebase/lists"}