From 255b810a3c9c60f8b0b82bfe657317a34e19d9ba Mon Sep 17 00:00:00 2001 From: Scott Prue Date: Sun, 13 Oct 2019 02:16:16 -0600 Subject: [PATCH] v3.0.2 * fix(types): update `see` paths that are not valid and add missing * fix(docs): update `see` paths that are not valid * fix(docs): remove see parameter from generated api docs * fix(docs): update `book.json` to have v3.0.0 selected --- README.md | 2 +- SUMMARY.md | 1 + bin/api-docs-generate.js | 25 ++- book.json | 10 +- docs/api/README.md | 9 +- docs/api/ReactReduxFirebaseProvider.md | 7 +- docs/api/ReduxFirestoreProvider.md | 3 +- docs/api/firebaseConnect.md | 9 +- docs/api/firebaseInstance.md | 267 ++++++++++++++----------- docs/api/firestoreConnect.md | 10 +- docs/api/helpers.md | 2 +- docs/api/useFirebase.md | 10 +- docs/api/useFirebaseConnect.md | 16 +- docs/api/useFirestore.md | 18 +- docs/api/useFirestoreConnect.md | 18 +- docs/api/withFirebase.md | 13 +- docs/api/withFirestore.md | 21 +- index.d.ts | 185 ++++++++++------- package-lock.json | 2 +- package.json | 2 +- src/ReactReduxFirebaseContext.js | 2 +- src/ReactReduxFirebaseProvider.js | 6 +- src/ReduxFirestoreContext.js | 2 +- src/ReduxFirestoreProvider.js | 4 +- src/createFirebaseInstance.js | 58 ++++-- src/firebaseConnect.js | 4 +- src/firestoreConnect.js | 4 +- src/helpers.js | 2 +- src/useFirebase.js | 4 +- src/useFirebaseConnect.js | 17 +- src/useFirestore.js | 8 +- src/useFirestoreConnect.js | 19 +- src/withFirebase.js | 4 +- src/withFirestore.js | 4 +- 34 files changed, 453 insertions(+), 315 deletions(-) diff --git a/README.md b/README.md index 440b1e4ca..b37d7fe7f 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ If you're not, you can access the library on [unpkg](https://unpkg.com/redux-fir ### Older Versions -Interested in support for versions of [`react-redux`](https://github.com/reduxjs/react-redux) before v6 or the [new react context API](https://reactjs.org/docs/context.html)? Checkout the `v2.*.*` versions (installed through `npm i --save react-redux-firebase^@2.5.0`). +Interested in support for versions of [`react-redux`](https://github.com/reduxjs/react-redux) before v6 or the [new react context API](https://reactjs.org/docs/context.html)? Checkout [the `v2.*.*` versions](https://github.com/prescottprue/react-redux-firebase/tree/v2) (installed through `npm i --save react-redux-firebase^@2.5.0`). ## Use diff --git a/SUMMARY.md b/SUMMARY.md index d47f2df94..abb07a834 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -31,6 +31,7 @@ * [useFirebase](/docs/api/useFirebase.md) * [useFirebaseConnect](/docs/api/useFirebaseConnect.md) * [useFirestore](/docs/api/useFirestore.md) + * [useFirestoreConnect](/docs/api/useFirebaseConnect.md) * HOCs * [firebaseConnect](/docs/api/firebaseConnect.md) * [withFirebase](/docs/api/withFirebase.md) diff --git a/bin/api-docs-generate.js b/bin/api-docs-generate.js index 1496b9bd1..492bcd7cb 100644 --- a/bin/api-docs-generate.js +++ b/bin/api-docs-generate.js @@ -1,13 +1,31 @@ /* eslint-disable no-console */ const exec = require('child-process-promise').exec const fs = require('fs') +const { promisify } = require('util') + +const readFilePromise = promisify(fs.readFile) +const writeFilePromise = promisify(fs.writeFile) const SRC_FOLDER = 'src' +const API_DOCS_FOLDER = 'docs/api' const pathsToSkip = ['index.js', 'utils', '.DS_Store', 'actions'] const fileRenames = { 'createFirebaseInstance.js': 'firebaseInstance' } +/** + * Remove see field from markdown file + * @param {string} filePath - Path of file to remove see field from + * @returns {Promise} Resolves after all instances of see parameter are removed + */ +function removeSeeFromMarkdown(filePath) { + return readFilePromise(filePath).then(fileContentsBuffer => { + const fileContents = fileContentsBuffer.toString() + const cleanedContents = fileContents.replace(/\n-.*\*\*See.*/g, '') + return writeFilePromise(filePath, cleanedContents) + }) +} + /** * @param {object} file - File object for which to generate docs * @returns {Promise} Resolves after running docs generation @@ -16,11 +34,14 @@ function generateDocForFile(file) { return exec( `$(npm bin)/documentation build ${SRC_FOLDER}/${ file.src - } -f md -o docs/api/${file.dest} --shallow` + } -f md -o ${API_DOCS_FOLDER}/${file.dest} --shallow` ) .then(res => { console.log('Successfully generated', file.dest || file) - return res + return removeSeeFromMarkdown( + `${process.cwd()}/${API_DOCS_FOLDER}/${file.dest}` + ) + // return res }) .catch(error => { console.log('error generating doc: ', error.message || error) diff --git a/book.json b/book.json index b8ca020b5..fe4264984 100644 --- a/book.json +++ b/book.json @@ -22,13 +22,13 @@ "gitbookConfigURL": "https://storage.googleapis.com/docs.react-redux-firebase.com/book.json", "options": [ { - "value": "http://docs.react-redux-firebase.com/history/v2.0.0/", - "text": "Version 2.0.0", - "selected": true + "value": "http://react-redux-firebase.com/", + "text": "Version 3.0.0", + "selected": true }, { - "value": "http://docs.react-redux-firebase.com/history/v3.0.0/", - "text": "Version 3.0.0" + "value": "http://docs.react-redux-firebase.com/history/v2.0.0/", + "text": "Version 2.0.0" }, { "value": "http://docs.react-redux-firebase.com/history/v1.5.0/", diff --git a/docs/api/README.md b/docs/api/README.md index 5d9ba43b3..48861377d 100644 --- a/docs/api/README.md +++ b/docs/api/README.md @@ -3,18 +3,17 @@ Just like [redux](http://redux.js.org/docs/api/index.html), the react-redux-firebase API surface is intentionally as small as possible. ## Top-Level Exports -* [firebaseConnect](/docs/api/firebaseConnect.md#firebaseconnect) -* [firestoreConnect](/docs/api/firestoreConnect.md#firebaseconnect) -* [withFirebase](/docs/api/withFirebase.md) -* [withFirestore](/docs/api/withFirestore.md) * [useFirebase](/docs/api/useFirebase.md#usefirebase) * [useFirebaseConnect](/docs/api/useFirebaseConnect.md#usefirebaseconnect) * [useFirestore](/docs/api/useFirestore.md#usefirestore) * [useFirestoreConnect](/docs/api/useFirestoreConnect.md#usefirebaseconnect) +* [firebaseConnect](/docs/api/firebaseConnect.md#firebaseconnect) +* [withFirebase](/docs/api/withFirebase.md) +* [firestoreConnect](/docs/api/firestoreConnect.md) +* [withFirestore](/docs/api/withFirestore.md) * [reducer](/docs/api/reducer.md) (also exported as `firebaseReducer`) * [constants](/docs/api/constants.md) * [actionTypes](/docs/api/constants.md) -* [helpers](/docs/api/helpers.md) * [isLoaded](/docs/api/helpers.md#isLoaded) * [isEmpty](/docs/api/helpers.md#isEmpty) * [populate](/docs/api/helpers.md#populate) diff --git a/docs/api/ReactReduxFirebaseProvider.md b/docs/api/ReactReduxFirebaseProvider.md index 7ab0904fa..006a4ad8a 100644 --- a/docs/api/ReactReduxFirebaseProvider.md +++ b/docs/api/ReactReduxFirebaseProvider.md @@ -7,10 +7,9 @@ ## ReactReduxFirebaseProvider -- **See: [http://docs.react-redux-firebase.com/history/v3.0.0/docs/api/ReactReduxFirebaseProvider.html][3]** -Provider for context containing extended firebase instance created -by react-redux-firebase +Provider for context containing extended firebase +instance created by react-redux-firebase. ### Parameters @@ -28,7 +27,7 @@ Returns **React.Context.Provider** Provider for react-redux-firebase context [2]: #parameters -[3]: http://docs.react-redux-firebase.com/history/v3.0.0/docs/api/ReactReduxFirebaseProvider.html +[3]: https://react-redux-firebase.com/api/docs/ReactReduxFirebaseProvider.html [4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object diff --git a/docs/api/ReduxFirestoreProvider.md b/docs/api/ReduxFirestoreProvider.md index 38876f0e5..84aaf7c25 100644 --- a/docs/api/ReduxFirestoreProvider.md +++ b/docs/api/ReduxFirestoreProvider.md @@ -7,7 +7,6 @@ ## ReduxFirestoreProvider -- **See: [http://docs.react-redux-firebase.com/history/v3.0.0/docs/api/ReduxFirestoreProvider.html][3]** Provider for context containing extended firestore instance created by react-redux-firebase @@ -28,7 +27,7 @@ Returns **React.Context.Provider** Provider for redux-firestore context [2]: #parameters -[3]: http://docs.react-redux-firebase.com/history/v3.0.0/docs/api/ReduxFirestoreProvider.html +[3]: https://react-redux-firebase.com/docs/api/ReduxFirestoreProvider.html [4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object diff --git a/docs/api/firebaseConnect.md b/docs/api/firebaseConnect.md index a97414dee..cbe967cb1 100644 --- a/docs/api/firebaseConnect.md +++ b/docs/api/firebaseConnect.md @@ -9,7 +9,12 @@ ## firebaseConnect -- **See: [http://react-redux-firebase.com/api/firebaseConnect.html][5]** +**Extends React.Component** + + +React Higher Order Component that automatically listens/unListens to +Firebase Real Time Database on mount/unmount of the component. This uses +React's Component Lifecycle hooks. ### Parameters @@ -104,7 +109,7 @@ Returns **React.Component** Component wrapped in context [4]: #parameters-1 -[5]: http://react-redux-firebase.com/api/firebaseConnect.html +[5]: https://react-redux-firebase.com/docs/api/firebaseConnect.html [6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array diff --git a/docs/api/firebaseInstance.md b/docs/api/firebaseInstance.md index ab92c0555..0241a178b 100644 --- a/docs/api/firebaseInstance.md +++ b/docs/api/firebaseInstance.md @@ -83,7 +83,6 @@ Returns **[object][66]** Extended Firebase instance ## set -- **See: [http://docs.react-redux-firebase.com/history/v3.0.0/docs/api/firebaseInstance.html#set][68] import React, { Component } from 'react' import PropTypes from 'prop-types' import { firebaseConnect } from 'react-redux-firebase' @@ -96,41 +95,41 @@ Returns **[object][66]** Extended Firebase instance } export default firebaseConnect()(Example)** -Sets data to Firebase. More info available in -[the docs][69]. +Sets data to Firebase. ### Parameters -- `path` **[string][70]** Path to location on Firebase which to set -- `value` **([object][66] \| [string][70] \| [boolean][71] \| [number][72])** Value to write to Firebase +- `path` **[string][69]** Path to location on Firebase which to set +- `value` **([object][66] \| [string][69] \| [boolean][70] \| [number][71])** Value to write to Firebase - `onComplete` **[Function][67]** Function to run on complete (`not required`) -Returns **[Promise][73]** Containing reference snapshot +Returns **[Promise][72]** Containing reference snapshot ## setWithMeta + Sets data to Firebase along with meta data. Currently, this includes createdAt and createdBy. _Warning_ using this function may have unintented consequences (setting createdAt even if data already -exists). More info available in [the docs][74]. +exists). ### Parameters -- `path` **[string][70]** Path to location on Firebase which to set -- `value` **([object][66] \| [string][70] \| [boolean][71] \| [number][72])** Value to write to Firebase +- `path` **[string][69]** Path to location on Firebase which to set +- `value` **([object][66] \| [string][69] \| [boolean][70] \| [number][71])** Value to write to Firebase - `onComplete` **[Function][67]** Function to run on complete (`not required`) -Returns **[Promise][73]** Containing reference snapshot +Returns **[Promise][72]** Containing reference snapshot ## push -Pushes data to Firebase. More info -available in [the docs][75]. + +Pushes data to Firebase. ### Parameters -- `path` **[string][70]** Path to location on Firebase which to push -- `value` **([object][66] \| [string][70] \| [boolean][71] \| [number][72])** Value to push to Firebase +- `path` **[string][69]** Path to location on Firebase which to push +- `value` **([object][66] \| [string][69] \| [boolean][70] \| [number][71])** Value to push to Firebase - `onComplete` **[Function][67]** Function to run on complete (`not required`) ### Examples @@ -152,31 +151,31 @@ function Example({ firebase: { push } }) { export default firebaseConnect()(Example) ``` -Returns **[Promise][73]** Containing reference snapshot +Returns **[Promise][72]** Containing reference snapshot ## pushWithMeta + Pushes data to Firebase along with meta data. Currently, -this includes createdAt and createdBy. More info -available in [the docs][76]. +this includes createdAt and createdBy. ### Parameters -- `path` **[string][70]** Path to location on Firebase which to set -- `value` **([object][66] \| [string][70] \| [boolean][71] \| [number][72])** Value to write to Firebase +- `path` **[string][69]** Path to location on Firebase which to set +- `value` **([object][66] \| [string][69] \| [boolean][70] \| [number][71])** Value to write to Firebase - `onComplete` **[Function][67]** Function to run on complete (`not required`) -Returns **[Promise][73]** Containing reference snapshot +Returns **[Promise][72]** Containing reference snapshot ## update Updates data on Firebase and sends new data. More info -available in [the docs][74]. +available in [the docs][73]. ### Parameters -- `path` **[string][70]** Path to location on Firebase which to update -- `value` **([object][66] \| [string][70] \| [boolean][71] \| [number][72])** Value to update to Firebase +- `path` **[string][69]** Path to location on Firebase which to update +- `value` **([object][66] \| [string][69] \| [boolean][70] \| [number][71])** Value to update to Firebase - `onComplete` **[Function][67]** Function to run on complete (`not required`) ### Examples @@ -202,34 +201,34 @@ function Example({ firebase: { update } }) { export default firebaseConnect()(Example) ``` -Returns **[Promise][73]** Containing reference snapshot +Returns **[Promise][72]** Containing reference snapshot ## updateWithMeta + Updates data on Firebase along with meta. _Warning_ using this function may have unintented consequences (setting -createdAt even if data already exists). More info available -in [the docs][77]. +createdAt even if data already exists). ### Parameters -- `path` **[string][70]** Path to location on Firebase which to update -- `value` **([object][66] \| [string][70] \| [boolean][71] \| [number][72])** Value to update to Firebase +- `path` **[string][69]** Path to location on Firebase which to update +- `value` **([object][66] \| [string][69] \| [boolean][70] \| [number][71])** Value to update to Firebase - `onComplete` **[Function][67]** Function to run on complete (`not required`) -Returns **[Promise][73]** Containing reference snapshot +Returns **[Promise][72]** Containing reference snapshot ## remove + Removes data from Firebase at a given path. **NOTE** A seperate action is not dispatched unless `dispatchRemoveAction: true` is provided to config on store creation. That means that a listener must be attached in order for state to be updated when calling remove. -More info available in [the docs][78]. ### Parameters -- `path` **[string][70]** Path to location on Firebase which to remove +- `path` **[string][69]** Path to location on Firebase which to remove - `onComplete` **[Function][67]** Function to run on complete (`not required`) - `options` **[Function][67]** Options object @@ -252,19 +251,19 @@ function Example({ firebase: { remove } }) { export default firebaseConnect()(Example) ``` -Returns **[Promise][73]** Containing reference snapshot +Returns **[Promise][72]** Containing reference snapshot ## uniqueSet + Sets data to Firebase only if the path does not already exist, otherwise it rejects. Internally uses a Firebase transaction to prevent a race condition between seperate clients calling uniqueSet. -More info available in [the docs][79]. ### Parameters -- `path` **[string][70]** Path to location on Firebase which to set -- `value` **([object][66] \| [string][70] \| [boolean][71] \| [number][72])** Value to write to Firebase +- `path` **[string][69]** Path to location on Firebase which to set +- `value` **([object][66] \| [string][69] \| [boolean][70] \| [number][71])** Value to write to Firebase - `onComplete` **[Function][67]** Function to run on complete (`not required`) ### Examples @@ -286,85 +285,87 @@ function Example({ firebase: { uniqueSet } }) { export default firebaseConnect()(Example) ``` -Returns **[Promise][73]** Containing reference snapshot +Returns **[Promise][72]** Containing reference snapshot ## uploadFile + Upload a file to Firebase Storage with the option to store its metadata in Firebase Database. More info available in [the docs][80]. ### Parameters -- `path` **[string][70]** Path to location on Firebase which to set +- `path` **[string][69]** Path to location on Firebase which to set - `file` **File** File object to upload (usually first element from array output of select-file or a drag/drop `onDrop`) -- `dbPath` **[string][70]** Database path to place uploaded file metadata +- `dbPath` **[string][69]** Database path to place uploaded file metadata - `options` **[object][66]** Options - - `options.name` **[string][70]** Name of the file + - `options.name` **[string][69]** Name of the file - `options.metdata` **[object][66]** Metadata for the file (passed as second argument to storage.put calls) -Returns **[Promise][73]** Containing the File object +Returns **[Promise][72]** Containing the File object ## uploadFiles + Upload multiple files to Firebase Storage with the option -to store their metadata in Firebase Database. More info available -in [the docs][81]. +to store their metadata in Firebase Database. ### Parameters -- `path` **[string][70]** Path to location on Firebase which to set +- `path` **[string][69]** Path to location on Firebase which to set - `files` **[Array][82]** Array of File objects to upload (usually from a select-file or a drag/drop `onDrop`) -- `dbPath` **[string][70]** Database path to place uploaded files metadata. +- `dbPath` **[string][69]** Database path to place uploaded files metadata. - `options` **[object][66]** Options - - `options.name` **[string][70]** Name of the file + - `options.name` **[string][69]** Name of the file -Returns **[Promise][73]** Containing an array of File objects +Returns **[Promise][72]** Containing an array of File objects ## deleteFile + Delete a file from Firebase Storage with the option to -remove its metadata in Firebase Database. More info available -in [the docs][83]. +remove its metadata in Firebase Database. ### Parameters -- `path` **[string][70]** Path to location on Firebase which to set -- `dbPath` **[string][70]** Database path to place uploaded file metadata +- `path` **[string][69]** Path to location on Firebase which to set +- `dbPath` **[string][69]** Database path to place uploaded file metadata -Returns **[Promise][73]** Containing the File object +Returns **[Promise][72]** Containing the File object ## watchEvent + Watch event. **Note:** this method is used internally so examples have not yet been created, and it may not work as expected. -More info available in [the docs][84]. ### Parameters -- `type` **[string][70]** Type of watch event -- `path` **[string][70]** Path to location on Firebase which to set listener -- `storeAs` **[string][70]** Name of listener results within redux store +- `type` **[string][69]** Type of watch event +- `path` **[string][69]** Path to location on Firebase which to set listener +- `storeAs` **[string][69]** Name of listener results within redux store - `options` **[object][66]** Event options object (optional, default `{}`) - `options.queryParams` **[Array][82]** List of parameters for the query - - `options.queryId` **[string][70]** id of the query + - `options.queryId` **[string][69]** id of the query -Returns **([Promise][73] | void)** Results of calling watch event +Returns **([Promise][72] | void)** Results of calling watch event ## unWatchEvent + Unset a listener watch event. **Note:** this method is used internally so examples have not yet been created, and it may not work -as expected. More info available in [the docs][85]. +as expected. ### Parameters -- `type` **[string][70]** Type of watch event -- `path` **[string][70]** Path to location on Firebase which to unset listener -- `queryId` **[string][70]** Id of the listener +- `type` **[string][69]** Type of watch event +- `path` **[string][69]** Path to location on Firebase which to unset listener +- `queryId` **[string][69]** Id of the listener - `options` **[object][66]** Event options object (optional, default `{}`) Returns **void** @@ -385,45 +386,49 @@ return a Promise. - `options` **[object][66]** The options object that you would like to pass to your watchArray generating function. -Returns **[Promise][73]** Resolves with an array of watchEvent results +Returns **[Promise][72]** Resolves with an array of watchEvent results ## login + Logs user into Firebase. For examples, visit the -[auth section of the docs][86] +[auth section of the docs][88] or the +[auth recipes section][89]. ### Parameters - `credentials` **[object][66]** Credentials for authenticating - - `credentials.provider` **[string][70]** External provider (google | + - `credentials.provider` **[string][69]** External provider (google | facebook | twitter) - - `credentials.type` **[string][70]** Type of external authentication + - `credentials.type` **[string][69]** Type of external authentication (popup | redirect) (only used with provider) - - `credentials.email` **[string][70]** Credentials for authenticating - - `credentials.password` **[string][70]** Credentials for authenticating (only used with email) + - `credentials.email` **[string][69]** Credentials for authenticating + - `credentials.password` **[string][69]** Credentials for authenticating (only used with email) -Returns **[Promise][73]** Containing user's auth data +Returns **[Promise][72]** Containing user's auth data ## handleRedirectResult Logs user into Firebase using external. For examples, visit the -[auth section][87] +[auth section][90] ### Parameters - `authData` **[object][66]** Auth data from Firebase's getRedirectResult -Returns **[Promise][73]** Containing user's profile +Returns **[Promise][72]** Containing user's profile ## logout + Logs user out of Firebase and empties firebase state from redux store -Returns **[Promise][73]** Resolves after logout is complete +Returns **[Promise][72]** Resolves after logout is complete ## createUser + Creates a new user in Firebase authentication. If `userProfile` config option is set, user profiles will be set to this location. @@ -431,47 +436,51 @@ location. ### Parameters - `credentials` **[object][66]** Credentials for authenticating - - `credentials.email` **[string][70]** Credentials for authenticating - - `credentials.password` **[string][70]** Credentials for authenticating (only used with email) + - `credentials.email` **[string][69]** Credentials for authenticating + - `credentials.password` **[string][69]** Credentials for authenticating (only used with email) - `profile` **[object][66]** Data to include within new user profile -Returns **[Promise][73]** Containing user's auth data +Returns **[Promise][72]** Containing user's auth data ## resetPassword + Sends password reset email ### Parameters - `credentials` **[object][66]** Credentials for authenticating - - `credentials.email` **[string][70]** Credentials for authenticating + - `credentials.email` **[string][69]** Credentials for authenticating -Returns **[Promise][73]** Resolves after password reset email is sent +Returns **[Promise][72]** Resolves after password reset email is sent ## confirmPasswordReset + Confirm that a user's password has been reset ### Parameters -- `code` **[string][70]** Password reset code to verify -- `password` **[string][70]** New Password to confirm reset to +- `code` **[string][69]** Password reset code to verify +- `password` **[string][69]** New Password to confirm reset to -Returns **[Promise][73]** Resolves after password reset is confirmed +Returns **[Promise][72]** Resolves after password reset is confirmed ## verifyPasswordResetCode + Verify that a password reset code from a password reset email is valid ### Parameters -- `code` **[string][70]** Password reset code to verify +- `code` **[string][69]** Password reset code to verify -Returns **[Promise][73]** Containing user auth info +Returns **[Promise][72]** Containing user auth info ## updateProfile + Update user profile on Firebase Real Time Database or Firestore (if `useFirestoreForProfile: true` config passed to reactReduxFirebase). Real Time Database update uses `update` method @@ -482,59 +491,64 @@ internally while updating profile on Firestore uses `set` with - `profileUpdate` **[object][66]** Profile data to place in new profile - `options` **[object][66]** Options object (used to change how profile update occurs) - - `options.useSet` **[boolean][71]** Use set with merge instead of + - `options.useSet` **[boolean][70]** Use set with merge instead of update. Setting to `false` uses update (can cause issue of profile document does not exist). Note: Only used when updating profile on Firestore (optional, default `true`) - - `options.merge` **[boolean][71]** Whether or not to use merge when + - `options.merge` **[boolean][70]** Whether or not to use merge when setting profile. Note: Only used when updating profile on Firestore (optional, default `true`) -Returns **[Promise][73]** Returns after updating profile within database +Returns **[Promise][72]** Returns after updating profile within database ## updateAuth + Update Auth profile object ### Parameters - `authUpdate` **[object][66]** Update to be auth object -- `updateInProfile` **[boolean][71]** Update in profile +- `updateInProfile` **[boolean][70]** Update in profile -Returns **[Promise][73]** Returns after updating auth profile +Returns **[Promise][72]** Returns after updating auth profile ## updateEmail + Update user's email ### Parameters -- `newEmail` **[string][70]** Update to be auth object -- `updateInProfile` **[boolean][71]** Update in profile +- `newEmail` **[string][69]** Update to be auth object +- `updateInProfile` **[boolean][70]** Update in profile -Returns **[Promise][73]** Resolves after email is updated in user's auth +Returns **[Promise][72]** Resolves after email is updated in user's auth ## reloadAuth + Reload user's auth object. Must be authenticated. -Returns **[Promise][73]** Resolves after reloading firebase auth +Returns **[Promise][72]** Resolves after reloading firebase auth ## linkWithCredential + Links the user account with the given credentials. ### Parameters - `credential` **firebase.auth.AuthCredential** The auth credential -Returns **[Promise][73]** Resolves after linking auth with a credential +Returns **[Promise][72]** Resolves after linking auth with a credential ## actionCreators + ### Parameters - `credential` **firebase.auth.ConfirmationResult** The auth credential -Returns **[Promise][73]** +Returns **[Promise][72]** ## actionCreators @@ -564,7 +578,6 @@ Returns **firebase.database.Auth** ## getFirebase -- **See: [http://react-redux-firebase.com/api/getFirebase.html][88]** Get internal Firebase instance with methods which are wrapped with action dispatches. Useful for integrations into external libraries such as redux-thunk and redux-observable. @@ -740,44 +753,72 @@ Returns **[object][66]** Firebase instance with methods which dispatch redux act [67]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function -[68]: http://docs.react-redux-firebase.com/history/v3.0.0/docs/api/firebaseInstance.html#set +[68]: https://react-redux-firebase.com/docs/api/firebaseInstance.html#set -[69]: http://docs.react-redux-firebase.com/history/v3.0.0/docs/api/props-firebase.html#set +[69]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String -[70]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String +[70]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean -[71]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean +[71]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number -[72]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number +[72]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise -[73]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise +[73]: https://react-redux-firebase.com/docs/api/firebaseInstance.html#update -[74]: http://docs.react-redux-firebase.com/history/v3.0.0/docs/api/props-firebase.html#update +[74]: https://react-redux-firebase.com/docs/api/firebaseInstance.html#push -[75]: http://docs.react-redux-firebase.com/history/v3.0.0/docs/api/props-firebase.html#push +[75]: https://react-redux-firebase.com/docs/api/firebaseInstance.html#pushwithmeta -[76]: http://docs.react-redux-firebase.com/history/v3.0.0/docs/api/props-firebase.html#pushWithMeta +[76]: https://react-redux-firebase.com/docs/api/firebaseInstance.html#updatewithmeta -[77]: http://docs.react-redux-firebase.com/history/v3.0.0/docs/api/props-firebase.html#updateWithMeta +[77]: https://react-redux-firebase.com/docs/api/firebaseInstance.html#remove -[78]: http://docs.react-redux-firebase.com/history/v3.0.0/docs/api/props-firebase.html#remove +[78]: https://react-redux-firebase.com/docs/api/firebaseInstance.html#uniqueset -[79]: http://docs.react-redux-firebase.com/history/v3.0.0/docs/api/props-firebase.html#uniqueSet +[79]: https://react-redux-firebase.com/docs/api/firebaseInstance.html#uploadfile -[80]: http://docs.react-redux-firebase.com/history/v3.0.0/docs/api/props-firebase.html#uploadFile +[80]: <> -[81]: http://docs.react-redux-firebase.com/history/v3.0.0/docs/api/props-firebase.html#uploadFiles +[81]: https://react-redux-firebase.com/docs/api/firebaseInstance.html#uploadfiles [82]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array -[83]: http://docs.react-redux-firebase.com/history/v3.0.0/docs/api/props-firebase.html#deleteFile +[83]: https://react-redux-firebase.com/docs/api/firebaseInstance.html#deletefile + +[84]: https://react-redux-firebase.com/docs/api/firebaseInstance.html#watchevent + +[85]: https://react-redux-firebase.com/docs/api/firebaseInstance.html#unwatchevent + +[86]: https://react-redux-firebase.com/docs/auth.html#logincredentials + +[87]: https://react-redux-firebase.com/docs/api/firebaseInstance.html#login + +[88]: https://react-redux-firebase.com/docs/auth.html + +[89]: https://react-redux-firebase.com/docs/recipes/auth.html + +[90]: /docs/recipes/auth.md + +[91]: https://react-redux-firebase.com/docs/auth.html#logout + +[92]: https://react-redux-firebase.com/docs/auth.html#createuser + +[93]: https://react-redux-firebase.com/docs/api/firebaseInstance.html#resetpassword + +[94]: https://react-redux-firebase.com/docs/api/firebaseInstance.html#confirmpasswordreset + +[95]: https://react-redux-firebase.com/docs/api/firebaseInstance.html#verifypasswordreset + +[96]: https://react-redux-firebase.com/docs/api/firebaseInstance.html#updateprofile + +[97]: https://react-redux-firebase.com/docs/api/firebaseInstance.html#updateauth -[84]: http://docs.react-redux-firebase.com/history/v3.0.0/docs/api/props-firebase.html#watchEvent +[98]: https://react-redux-firebase.com/docs/api/firebaseInstance.html#updateemail -[85]: http://docs.react-redux-firebase.com/history/v3.0.0/docs/api/props-firebase.html#unwatchevent +[99]: https://react-redux-firebase.com/docs/api/firebaseInstance.html#reloadauth -[86]: /docs/auth.md +[100]: https://react-redux-firebase.com/docs/api/firebaseInstance.html#linkwithcredential -[87]: /docs/recipes/auth.md +[101]: https://react-redux-firebase.com/docs/api/firebaseInstance.html#signinwithphonenumber -[88]: http://react-redux-firebase.com/api/getFirebase.html +[102]: http://react-redux-firebase.com/api/getFirebase.html diff --git a/docs/api/firestoreConnect.md b/docs/api/firestoreConnect.md index 44a5801c1..74fe0a09d 100644 --- a/docs/api/firestoreConnect.md +++ b/docs/api/firestoreConnect.md @@ -9,7 +9,13 @@ ## firestoreConnect -- **See: [http://react-redux-firebase.com/api/firestoreConnect.html][5]** +**Extends React.Component** + + +Higher Order Component that automatically listens/unListens +to provided Cloud Firestore paths using React's Lifecycle hooks. Make sure you +have required/imported Cloud Firestore, including it's reducer, before +attempting to use. **Note** Populate is not yet supported. ### Parameters @@ -63,7 +69,7 @@ Returns **React.Component** Component wrapped in context [4]: #parameters-1 -[5]: http://react-redux-firebase.com/api/firestoreConnect.html +[5]: https://react-redux-firebase.com/docs/api/firestoreConnect.html [6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array diff --git a/docs/api/helpers.md b/docs/api/helpers.md index a3fdd03cb..29804e61b 100644 --- a/docs/api/helpers.md +++ b/docs/api/helpers.md @@ -217,7 +217,7 @@ const enhance = compose( // each todo has child 'owner' populated from matching uid in 'users' root // for loading un-populated todos use state.firebase.data.todos todos: populate(state.firebase, 'todos', populates), - }) + })) ) export default enhance(SomeComponent) diff --git a/docs/api/useFirebase.md b/docs/api/useFirebase.md index 4095aa3c8..1540a4275 100644 --- a/docs/api/useFirebase.md +++ b/docs/api/useFirebase.md @@ -7,7 +7,13 @@ ## useFirebase -- **See: [http://docs.react-redux-firebase.com/history/v3.0.0/docs/api/useFirebase.html][3]** + +React hook that provides `firebase` object. +Firebase is gathered from `store.firebase`, which is attached to store +by the store enhancer (`reactReduxFirebase`) during setup. +**NOTE**: This version of the Firebase library has extra methods, config, +and functionality which give it it's capabilities such as dispatching +actions. ### Examples @@ -40,6 +46,6 @@ Returns **[object][4]** Extended Firebase instance [2]: #examples -[3]: http://docs.react-redux-firebase.com/history/v3.0.0/docs/api/useFirebase.html +[3]: https://react-redux-firebase.com/docs/api/useFirebase.html [4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object diff --git a/docs/api/useFirebaseConnect.md b/docs/api/useFirebaseConnect.md index f7f6647c7..9918d9583 100644 --- a/docs/api/useFirebaseConnect.md +++ b/docs/api/useFirebaseConnect.md @@ -8,7 +8,6 @@ ## useFirebaseConnect -- **See: [http://docs.react-redux-firebase.com/history/v3.0.0/docs/api/useFirebaseConnect.html][4]** Hook that automatically listens/unListens to provided firebase paths using React's useEffect hook. @@ -25,6 +24,7 @@ using React's useEffect hook. _Ordered Data_ ```javascript +import React from 'react' import { useSelector } from 'react-redux' import { useFirebaseConnect } from 'react-redux-firebase' @@ -44,31 +44,31 @@ export default function Todos() { _Data that depends on props_ ```javascript +import React from 'react' import { compose } from 'redux' import { useSelector } from 'react-redux' import { useFirebaseConnect } from 'react-redux-firebase' -function Post({ postId }) { +export default function Post({ postId }) { useFirebaseConnect(`posts/${postId}`) // sync /posts/postId from firebase into redux - const post = useSelector(({ firebase }) => state.firebase.ordered.posts && state.firebase.ordered.posts[postId]) + const post = useSelector(({ firebase: { ordered: { posts } } }) => posts && posts[postId]) return (
{JSON.stringify(post, null, 2)}
) } - -export default enhance(Post) ``` _Data that depends on props, an array as a query_ ```javascript +import React from 'react' import { compose } from 'redux' import { useSelector } from 'react-redux' import { useFirebaseConnect, getVal } from 'react-redux-firebase' -function Post({ post, postId }) { +export default function Post({ postId }) { useFirebaseConnect([`posts/${postId}`], [postId]) // sync /posts/postId from firebase into redux const post = useSelector(state => { return state.firebase.ordered.posts && state.firebase.ordered.posts[postId] @@ -79,8 +79,6 @@ function Post({ post, postId }) { ) } - -export default Post ``` [1]: #usefirebaseconnect @@ -89,7 +87,7 @@ export default Post [3]: #examples -[4]: http://docs.react-redux-firebase.com/history/v3.0.0/docs/api/useFirebaseConnect.html +[4]: https://react-redux-firebase.com/docs/api/useFirebaseConnect.html [5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object diff --git a/docs/api/useFirestore.md b/docs/api/useFirestore.md index 281667c04..a48c10375 100644 --- a/docs/api/useFirestore.md +++ b/docs/api/useFirestore.md @@ -7,7 +7,11 @@ ## useFirestore -- **See: [http://docs.react-redux-firebase.com/history/v3.0.0/docs/api/useFirestore.html][3]** + +React hook that return firestore object. +Firestore instance is gathered from `store.firestore`, which is attached +to store by the store enhancer (`reduxFirestore`) during setup of +[`redux-firestore`][4] ### Examples @@ -17,7 +21,7 @@ _Basic_ import React from 'react' import { useFirestore } from 'react-redux-firebase' -function AddData({ firebase: { add } }) { +export default function AddData({ firebase: { add } }) { const firestore = useFirestore() function addTodo() { @@ -33,16 +37,16 @@ function AddData({ firebase: { add } }) { ) } - -export default AddTodo ``` -Returns **[object][4]** Extended Firestore instance +Returns **[object][5]** Extended Firestore instance [1]: #usefirestore [2]: #examples -[3]: http://docs.react-redux-firebase.com/history/v3.0.0/docs/api/useFirestore.html +[3]: https://react-redux-firebase.com/docs/api/useFirestore.html + +[4]: https://github.com/prescottprue/redux-firestore -[4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object +[5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object diff --git a/docs/api/useFirestoreConnect.md b/docs/api/useFirestoreConnect.md index 11cd7234d..200d86d56 100644 --- a/docs/api/useFirestoreConnect.md +++ b/docs/api/useFirestoreConnect.md @@ -8,7 +8,6 @@ ## useFirestoreConnect -- **See: [http://docs.react-redux-firebase.com/history/v3.0.0/docs/api/useFirestoreConnect.html][4]** React hook that automatically listens/unListens to provided Cloud Firestore paths. Make sure you have required/imported @@ -31,7 +30,7 @@ import { map } from 'lodash' import { useSelector } from 'react-redux' import { useFirebaseConnect } from 'react-redux-firebase' -function TodosList() { +export default function TodosList() { useFirebaseConnect('todos') // sync todos collection from Firestore into redux const todos = useSelector(state => state.firebase.data.todos) return ( @@ -42,7 +41,6 @@ function TodosList() { ) } -export default TodosList ``` _Object as query_ @@ -53,21 +51,15 @@ import { get } from 'lodash' import { connect } from 'react-redux' import { useFirebaseConnect } from 'react-redux-firebase' -function TodoItem({ todoId, todoData }) { +export default function TodoItem({ todoId }) { useFirebaseConnect(() => ({ collection: 'todos', doc: todoId - }), [todoId]) // include dependency in the hook + })) + const todo = useSelector(({ firebase: { data } }) => data.todos && data.todos[todoId]) return
{JSON.stringify(todoData)}
} - -// pass todo data from redux as props.todosList -export default compose( - connect((state) => ({ - todoData: get(state, ['firestore', 'data', 'todos', todoId]) - }) -)(TodoItem) ``` [1]: #usefirestoreconnect @@ -76,7 +68,7 @@ export default compose( [3]: #examples -[4]: http://docs.react-redux-firebase.com/history/v3.0.0/docs/api/useFirestoreConnect.html +[4]: https://react-redux-firebase.com/docs/api/useFirestoreConnect.html [5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object diff --git a/docs/api/withFirebase.md b/docs/api/withFirebase.md index fffae5923..df780e8d8 100644 --- a/docs/api/withFirebase.md +++ b/docs/api/withFirebase.md @@ -10,7 +10,16 @@ ## withFirebase -- **See: [http://react-redux-firebase.com/api/withFirebase.html][6]** +**Extends React.Component** + + +Higher Order Component that provides `firebase` and +`dispatch` as a props to React Components. Firebase is gathered from +`store.firebase`, which is attached to store by the store enhancer +(`reactReduxFirebase`) during setup. +**NOTE**: This version of the Firebase library has extra methods, config, +and functionality which give it it's capabilities such as dispatching +actions. ### Parameters @@ -92,7 +101,7 @@ Returns **React.Component** WrappedComponent wrapped with firebase context [5]: #parameters-1 -[6]: http://react-redux-firebase.com/api/withFirebase.html +[6]: http://react-redux-firebase.com/docs/api/withFirebase.html [7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function diff --git a/docs/api/withFirestore.md b/docs/api/withFirestore.md index 9b787ce36..4212e1549 100644 --- a/docs/api/withFirestore.md +++ b/docs/api/withFirestore.md @@ -10,7 +10,14 @@ ## withFirestore -- **See: [http://react-redux-firebase.com/api/withFirestore.html][6]** +**Extends React.Component** + + +Higher Order Component that attaches `firestore`, `firebase` +and `dispatch` as props to React Components. Firebase instance is gathered +from `store.firestore`, which is attached to store by the store enhancer +(`reduxFirestore`) during setup of +[`redux-firestore`][7] ### Parameters @@ -68,7 +75,7 @@ const enhance = compose( export default enhance(AddTodo) ``` -Returns **[Function][7]** Which accepts a component to wrap and returns the +Returns **[Function][8]** Which accepts a component to wrap and returns the wrapped component ## WithFirestore @@ -77,7 +84,7 @@ WithFirebase wrapper component ### Parameters -- `props` **[object][8]** Component props +- `props` **[object][9]** Component props Returns **React.Component** WrappedComponent wrapped with firebase context @@ -91,8 +98,10 @@ Returns **React.Component** WrappedComponent wrapped with firebase context [5]: #parameters-1 -[6]: http://react-redux-firebase.com/api/withFirestore.html +[6]: http://react-redux-firebase.com/docs/api/withFirestore.html + +[7]: https://github.com/prescottprue/redux-firestore -[7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function +[8]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function -[8]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object +[9]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object diff --git a/index.d.ts b/index.d.ts index 7c88a5d9d..00792c263 100644 --- a/index.d.ts +++ b/index.d.ts @@ -27,6 +27,10 @@ export interface InferableComponentEnhancerWithProps< type mapper = (input: TInner) => TOutter +/** + * Redux action types for react-redux-firebase + * @see https://react-redux-firebase.com/docs/api/constants.html#actiontypes + */ export const actionTypes: { START: string SET: string @@ -71,6 +75,10 @@ export const actionTypes: { PROFILE_UPDATE_SUCCESS: string } +/** + * Constants used within react-redux-firbease + * @see https://react-redux-firebase.com/docs/api/constants.html + */ export const constants: { actionTypes: { AUTHENTICATION_INIT_FINISHED: string @@ -115,6 +123,9 @@ export const constants: { UNAUTHORIZED_ERROR: string UNSET_LISTENER: string } + /** + * @see https://react-redux-firebase.com/docs/api/constants.html#defaultconfig + */ defaultConfig: ReactReduxFirebaseConfig } @@ -130,7 +141,7 @@ interface RemoveOptions { /** * Firestore instance extended with methods which dispatch * redux actions. - * @see https://react-redux-firebase.com/api/firebaseInstance.html + * @see https://react-redux-firebase.com/docs/api/firebaseInstance.html */ interface ExtendedFirebaseInstance extends DatabaseTypes.FirebaseDatabase { initializeAuth: VoidFunction @@ -145,7 +156,7 @@ interface ExtendedFirebaseInstance extends DatabaseTypes.FirebaseDatabase { * @param value - Value to write to Firebase * @param onComplete - Function to run on complete (`not required`) * @returns Containing reference snapshot - * @see https://react-redux-firebase.com/api/firebaseInstance.html#set + * @see https://react-redux-firebase.com/docs/api/firebaseInstance.html#set */ set: ( path: string, @@ -161,7 +172,7 @@ interface ExtendedFirebaseInstance extends DatabaseTypes.FirebaseDatabase { * @param path - Path to location on Firebase which to set * @param value - Value to write to Firebase * @param onComplete - Function to run on complete (`not required`) - * @see https://react-redux-firebase.com/api/firebaseInstance.html#setWithMeta + * @see https://react-redux-firebase.com/docs/api/firebaseInstance.html#setWithMeta */ setWithMeta: ( path: string, @@ -174,7 +185,7 @@ interface ExtendedFirebaseInstance extends DatabaseTypes.FirebaseDatabase { * @param path - Path to location on Firebase which to push * @param value - Value to push to Firebase * @param onComplete - Function to run on complete - * @see https://react-redux-firebase.com/api/firebaseInstance.html#push + * @see https://react-redux-firebase.com/docs/api/firebaseInstance.html#push */ push: ( path: string, @@ -188,7 +199,7 @@ interface ExtendedFirebaseInstance extends DatabaseTypes.FirebaseDatabase { * @param path - Path to location on Firebase which to set * @param value - Value to write to Firebase * @param onComplete - Function to run on complete - * @see https://react-redux-firebase.com/api/firebaseInstance.html#pushWithMeta + * @see https://react-redux-firebase.com/docs/api/firebaseInstance.html#pushWithMeta */ pushWithMeta: ( path: string, @@ -218,7 +229,7 @@ interface ExtendedFirebaseInstance extends DatabaseTypes.FirebaseDatabase { * @param path - Path to location on Firebase which to update * @param value - Value to update to Firebase * @param onComplete - Function to run on complete (`not required`) - * @see https://react-redux-firebase.com/api/firebaseInstance.html#update + * @see https://react-redux-firebase.com/docs/api/firebaseInstance.html#update */ update: ( path: string, @@ -233,7 +244,7 @@ interface ExtendedFirebaseInstance extends DatabaseTypes.FirebaseDatabase { * @param path - Path to location on Firebase which to update * @param value - Value to update to Firebase * @param onComplete - Function to run on complete - * @see https://react-redux-firebase.com/api/firebaseInstance.html#updateWithMeta + * @see https://react-redux-firebase.com/docs/api/firebaseInstance.html#updateWithMeta */ updateWithMeta: ( path: string, @@ -250,7 +261,7 @@ interface ExtendedFirebaseInstance extends DatabaseTypes.FirebaseDatabase { * @param onComplete - Function to run on complete * @param options - Configuration for removal * @param [options.dispatchAction=true] - Whether or not to dispatch REMOVE action - * @see https://react-redux-firebase.com/api/firebaseInstance.html#remove + * @see https://react-redux-firebase.com/docs/api/firebaseInstance.html#remove */ remove: ( path: string, @@ -265,7 +276,7 @@ interface ExtendedFirebaseInstance extends DatabaseTypes.FirebaseDatabase { * @param path - Path to location on Firebase which to set * @param value - Value to write to Firebase * @param onComplete - Function to run on complete (`not required`) - * @see https://react-redux-firebase.com/api/firebaseInstance.html#uniqueset + * @see https://react-redux-firebase.com/docs/api/firebaseInstance.html#uniqueset */ uniqueSet: ( path: string, @@ -279,7 +290,7 @@ interface ExtendedFirebaseInstance extends DatabaseTypes.FirebaseDatabase { * @param path - Path to watch with watcher * @param storeAs - Location within redux to store value * @param options - List of parameters for the query - * @see https://react-redux-firebase.com/api/firebaseInstance.html#watchevent + * @see https://react-redux-firebase.com/docs/api/firebaseInstance.html#watchevent */ watchEvent: ( type: string, @@ -296,7 +307,7 @@ interface ExtendedFirebaseInstance extends DatabaseTypes.FirebaseDatabase { * @param path - Path to location on Firebase which to unset listener * @param queryId - Id of the listener * @param options - Event options object - * @see https://react-redux-firebase.com/api/firebaseInstance.html#watchevent + * @see https://react-redux-firebase.com/docs/api/firebaseInstance.html#watchevent */ unWatchEvent: ( type: string, @@ -312,7 +323,7 @@ interface ExtendedFirebaseInstance extends DatabaseTypes.FirebaseDatabase { * @param firebase - Firebase instance which to extend * @param configs - Configuration object * @param dispatch - Action dispatch function - * @see https://react-redux-firebase.com/api/firebaseInstance.html + * @see https://react-redux-firebase.com/docs/api/firebaseInstance.html */ export function createFirebaseInstance( firebase: any, @@ -333,7 +344,7 @@ export type QueryParamOptions = QueryParamOption | string[] /** * Options which can be passed to firebase query through react-redux-firebase - * @see https://react-redux-firebase.com/queries.html + * @see https://react-redux-firebase.com/docs/queries.html */ export interface ReactReduxFirebaseQuerySetting { path: string @@ -436,7 +447,8 @@ interface ExtendedFirestoreInstance extends FirestoreTypes.FirebaseFirestore { get: (docPath: string | ReduxFirestoreQuerySetting) => Promise /** - * Set data to firestore. More info available [in the docs](https://github.com/prescottprue/redux-firestore#set). + * Set data to firestore. + * @see https://github.com/prescottprue/redux-firestore#set */ set: ( docPath: string | ReduxFirestoreQuerySetting, @@ -444,7 +456,8 @@ interface ExtendedFirestoreInstance extends FirestoreTypes.FirebaseFirestore { ) => Promise /** - * Add document to firestore. More info available [in the docs](https://github.com/prescottprue/redux-firestore#add). + * Add document to firestore. + * @see https://github.com/prescottprue/redux-firestore#add */ add: ( collectionPath: string | ReduxFirestoreQuerySetting, @@ -452,7 +465,8 @@ interface ExtendedFirestoreInstance extends FirestoreTypes.FirebaseFirestore { ) => Promise<{ id: string }> /** - * Update document within firestore. More info available [in the docs](https://github.com/prescottprue/redux-firestore#update). + * Update document within firestore. + * @see https://github.com/prescottprue/redux-firestore#update */ update: ( docPath: string | ReduxFirestoreQuerySetting, @@ -460,29 +474,52 @@ interface ExtendedFirestoreInstance extends FirestoreTypes.FirebaseFirestore { ) => Promise /** - * Delete a document within firestore. More info available [in the docs](https://github.com/prescottprue/redux-firestore#delete). + * Delete a document within firestore. + * @see https://github.com/prescottprue/redux-firestore#delete */ delete: (docPath: string | ReduxFirestoreQuerySetting) => void /** * Executes the given updateFunction and then attempts to commit the changes applied within the - * transaction. More info available [in the docs](https://github.com/prescottprue/redux-firestore#runtransaction). + * transaction. + * @see https://github.com/prescottprue/redux-firestore#runtransaction */ runTransaction: typeof firebase.firestore.Firestore.runTransaction - // https://github.com/prescottprue/redux-firestore#onsnapshotsetlistener + /** + * Sets a listener within redux-firestore + * @see https://github.com/prescottprue/redux-firestore#onsnapshotsetlistener + */ onSnapshot: (options: ReduxFirestoreQuerySetting) => Promise + + /** + * Sets a listener within redux-firestore + * @see https://github.com/prescottprue/redux-firestore#onsnapshotsetlistener + */ setListener: (options: ReduxFirestoreQuerySetting) => Promise - //https://github.com/prescottprue/redux-firestore#setlisteners + /** + * Sets multiple firestore listeners created within redux-firestore + * @see https://github.com/prescottprue/redux-firestore#onsnapshotsetlisteners + */ setListeners: (optionsArray: ReduxFirestoreQuerySetting[]) => Promise - // https://github.com/prescottprue/redux-firestore#unsetlistener--unsetlisteners + /** + * Unset firestore listener created within redux-firestore + * @see https://github.com/prescottprue/redux-firestore#unsetlistener--unsetlistener + */ unsetListener: (options: ReduxFirestoreQuerySetting) => void + + /** + * Unset multiple firestore listeners created within redux-firestore + * @see https://github.com/prescottprue/redux-firestore#unsetlistener--unsetlisteners + */ unsetListeners: (options: ReduxFirestoreQuerySetting[]) => void } -// https://github.com/prescottprue/redux-firestore#other-firebase-statics +/** + * @see https://github.com/prescottprue/redux-firestore#other-firebase-statics + */ interface FirestoreStatics { FieldValue: FirestoreTypes.FieldValue FieldPath: FirestoreTypes.FieldPath @@ -539,7 +576,7 @@ interface UserProfile { /** * Firebase JS SDK Auth instance extended with methods which dispatch redux actions. - * @see https://react-redux-firebase.com/auth.html + * @see https://react-redux-firebase.com/docs/auth.html */ interface ExtendedAuthInstance { auth: () => AuthTypes.FirebaseAuth @@ -553,7 +590,7 @@ interface ExtendedAuthInstance { * (popup | redirect) (only used with provider) * @param credentials.email - Credentials for authenticating * @param credentials.password - Credentials for authenticating (only used with email) - * @see https://react-redux-firebase.com/auth.html#logincredentials + * @see https://react-redux-firebase.com/docs/auth.html#logincredentials */ login: (credentials: Credentials) => Promise @@ -563,7 +600,7 @@ interface ExtendedAuthInstance { * location. * @param credentials - Credentials for authenticating * @param profile - Data to include within new user profile - * @see https://react-redux-firebase.com/auth.html#createusercredentials-profile + * @see https://react-redux-firebase.com/docs/auth.html#createusercredentials-profile */ createUser: ( credentials: CreateUserCredentials, @@ -573,14 +610,14 @@ interface ExtendedAuthInstance { /** * Logs user out of Firebase and empties firebase state from * redux store. - * @see https://react-redux-firebase.com/auth.html#logout + * @see https://react-redux-firebase.com/docs/auth.html#logout */ logout: () => Promise /** * Sends password reset email. * @param credentials - Credentials for authenticating - * @see https://react-redux-firebase.com/auth.html#resetpasswordcredentials + * @see https://react-redux-firebase.com/docs/auth.html#resetpasswordcredentials */ resetPassword: ( credentials: AuthTypes.UserCredential, @@ -588,23 +625,29 @@ interface ExtendedAuthInstance { ) => Promise /** - * Confirm that a user's password has been reset. More info available - * [in the docs](https://react-redux-firebase.com/auth.html#confirmpasswordresetcode-newpassword). + * Confirm that a user's password has been reset. * @param code - Password reset code to verify * @param password - New Password to confirm reset to + * @see https://react-redux-firebase.com/docs/auth.html#confirmpasswordresetcode-newpassword */ confirmPasswordReset: AuthTypes.FirebaseAuth['confirmPasswordReset'] - // https://react-redux-firebase.com/auth.html#verifypasswordresetcodecode + // https://react-redux-firebase.com/docs/auth.html#verifypasswordresetcodecode verifyPasswordResetCode: AuthTypes.FirebaseAuth['verifyPasswordResetCode'] - // https://react-redux-firebase.com/auth.html#signinwithphonenumbercode + /** + * Signs in using a phone number in an async pattern (i.e. requires calling a second method). + * @param phoneNumber - Update to be auth object + * @param appVerifier - Update in profile + * @see https://react-redux-firebase.com/docs/api/firebaseInstance.html#signinwithphonenumber + */ signInWithPhoneNumber: AuthTypes.FirebaseAuth['signInWithPhoneNumber'] /** * Update user's email * @param newEmail - Update to be auth object * @param updateInProfile - Update in profile + * @see https://react-redux-firebase.com/docs/api/firebaseInstance.html#updateemail */ updateEmail: (newEmail: string, updateInProfile?: boolean) => Promise @@ -612,6 +655,7 @@ interface ExtendedAuthInstance { * Links the user account with the given credentials. Internally * calls `firebase.auth().currentUser.reload`. * @param credential - The auth credential + * @see https://react-redux-firebase.com/docs/api/firebaseInstance.html#reloadauth */ reloadAuth: (credential?: firebase.auth.AuthCredential | any) => Promise @@ -619,6 +663,7 @@ interface ExtendedAuthInstance { * Links the user account with the given credentials. Internally * calls `firebase.auth().currentUser.linkWithCredential`. * @param credential - Credential with which to link user account + * @see https://react-redux-firebase.com/docs/api/firebaseInstance.html#linkwithcredential */ linkWithCredential: ( credential: AuthTypes.AuthCredential @@ -628,6 +673,7 @@ interface ExtendedAuthInstance { * Update Auth Object * @param authUpdate - Update to be auth object * @param updateInProfile - Update in profile + * @see https://react-redux-firebase.com/docs/api/firebaseInstance.html#updateauth */ updateAuth: ( authUpdate: { @@ -642,7 +688,6 @@ interface ExtendedAuthInstance { * Firestore (if `useFirestoreForProfile: true` config passed to * reactReduxFirebase). Real Time Database update uses `update` method * internally while updating profile on Firestore uses `set` with merge. - * More info available [in the docs](https://react-redux-firebase.com/recipes/profile.html#update-profile). * @param profileUpdate - Profile data to place in new profile * @param options - Options object (used to change how profile * update occurs) @@ -651,23 +696,25 @@ interface ExtendedAuthInstance { * does not exist). Note: Only used when updating profile on Firestore * @param [options.merge=true] - Whether or not to use merge when * setting profile. Note: Only used when updating profile on Firestore + * @see https://react-redux-firebase.com/docs/api/firebaseInstance.html#updateprofile + * @see https://react-redux-firebase.com/docs/recipes/profile.html#update-profile */ updateProfile: (profile: Partial, options?: Object) => void } /** * Instance of Firebase Storage with methods that dispatch redux actions. - * More info available [in the docs](https://react-redux-firebase.com/storage.html) + * @see https://react-redux-firebase.com/docs/storage.html */ interface ExtendedStorageInstance { storage: () => StorageTypes.FirebaseStorage /** * Delete a file from Firebase Storage with the option to - * remove its metadata in Firebase Database. More info available - * in [the docs](https://react-redux-firebase.com/api/storage.html#deletefile). + * remove its metadata in Firebase Database. * @param path - Path to location on Firebase which to set * @param dbPath - Database path to place uploaded file metadata + * @see https://react-redux-firebase.com/docs/api/storage.html#deletefile */ deleteFile: ( path: string, @@ -676,14 +723,14 @@ interface ExtendedStorageInstance { /** * Upload a file to Firebase Storage with the option to store - * its metadata in Firebase Database. More info available - * in [the docs](https://react-redux-firebase.com/api/firebaseInstance.html#uploadFile). + * its metadata in Firebase Database. * @param path - Path to location on Firebase which to set * @param file - File object to upload (usually first element from * array output of select-file or a drag/drop `onDrop`) * @param dbPath - Database path to place uploaded file metadata * @param options - Options * @param options.name - Name of the file + * @see https://react-redux-firebase.com/docs/api/storage.html#uploadFile */ uploadFile: ( path: string, @@ -702,14 +749,14 @@ interface ExtendedStorageInstance { /** * Upload multiple files to Firebase Storage with the option - * to store their metadata in Firebase Database. More info available - * in [the docs](https://react-redux-firebase.com/api/firebaseInstance.html#uploadFiles). + * to store their metadata in Firebase Database. * @param path - Path to location on Firebase which to set * @param files - Array of File objects to upload (usually from * a select-file or a drag/drop `onDrop`) * @param dbPath - Database path to place uploaded files metadata. * @param options - Options * @param options.name - Name of the file + * @see https://react-redux-firebase.com/docs/api/storage.html#uploadFiles */ uploadFiles: ( path: string, @@ -735,7 +782,7 @@ export interface WithFirebaseProps { * React Higher Order Component that automatically listens/unListens to * Firebase Real Time Database on mount/unmount of the component. This uses * React's Component Lifecycle hooks. - * @see https://react-redux-firebase.com/api/firebaseConnect.html + * @see https://react-redux-firebase.com/docs/api/firebaseConnect.html */ export function firebaseConnect( queriesConfig?: @@ -753,28 +800,16 @@ export function firebaseConnect( * @param action.type - Type of Action being called * @param action.path - Path of action that was dispatched * @param action.data - Data associated with action - * @see https://react-redux-firebase.com/api/reducer.html + * @see https://react-redux-firebase.com/docs/api/reducer.html */ export function firebaseReducer( state: any, action: any ): FirebaseReducer.Reducer -/** - * Reducer for Firebase state - * @param state - Current Firebase Redux State (state.firebase) - * @param action - Action which will modify state - * @param action.type - Type of Action being called - * @param action.path - Path of action that was dispatched - * @param action.data - Data associated with action - */ -export function firebaseStateReducer( - state: any, - action: any -): FirestoreReducer.Reducer - /** * React HOC that attaches/detaches Cloud Firestore listeners on mount/unmount + * @see https://react-redux-firebase.com/docs/api/firestoreConnect.html */ export function firestoreConnect( connect?: mapper | ReduxFirestoreQueries @@ -790,7 +825,7 @@ export function firestoreConnect( * @param action.type - Type of Action being called * @param action.path - Path of action that was dispatched * @param action.data - Data associated with action - * @see https://react-redux-firebase.com/api/reducer.html + * @see https://react-redux-firebase.com/docs/api/reducer.html */ export function firestoreReducer( state: any, @@ -806,6 +841,7 @@ export function fixPath(path: string): string /** * Get internal Firebase instance with methods which are wrapped with action dispatches. Useful for * integrations into external libraries such as redux-thunk and redux-observable. + * @see https://react-redux-firebase.com/docs/api/getFirebase.html */ export function getFirebase(): ExtendedFirebaseInstance & ExtendedAuthInstance & ExtendedStorageInstance @@ -819,7 +855,7 @@ export function getFirebase(): ExtendedFirebaseInstance & ExtendedAuthInstance & * found in redux. This will cause `isLoaded` to always return true (since * value is set from the start). * @returns Data located at path within firebase. - * @see https://react-redux-firebase.com/api/helpers.html#getval + * @see https://react-redux-firebase.com/docs/api/helpers.html#getval */ export function getVal(firebase: any, path: string, notSetValue?: any): any @@ -828,7 +864,7 @@ export function getVal(firebase: any, path: string, notSetValue?: any): any * @param item - Item to check loaded status of. A comma seperated list * is also acceptable. * @returns Whether or not item is empty - * @see https://react-redux-firebase.com/api/helpers.html#isempty + * @see https://react-redux-firebase.com/docs/api/helpers.html#isempty */ export function isEmpty(...args: any[]): boolean @@ -837,14 +873,14 @@ export function isEmpty(...args: any[]): boolean * @param item - Item to check loaded status of. A comma separated * list is also acceptable. * @returns Whether or not item is loaded - * @see https://react-redux-firebase.com/api/helpers.html#isloaded + * @see https://react-redux-firebase.com/docs/api/helpers.html#isloaded */ export function isLoaded(...args: any[]): boolean /** * React hook that provides `firebase` object. Extended Firebase * instance is gathered from `ReactReduxFirebaseContext`. - * @see https://react-redux-firebase.com/api/useFirebase.html + * @see https://react-redux-firebase.com/docs/api/useFirebase.html */ export function useFirebase(): ExtendedFirebaseInstance & ExtendedAuthInstance & ExtendedStorageInstance @@ -856,7 +892,7 @@ export function useFirebase(): ExtendedFirebaseInstance & ExtendedAuthInstance & * from firestore. Can also be a function that returns the object or string. * @param deps - Dependency for memoizing query object. It's recommend * to include deps if using object, array or function as a query. - * @see https://react-redux-firebase.com/api/useFirestoreConnect.html + * @see https://react-redux-firebase.com/docs/api/useFirestoreConnect.html */ export function useFirebaseConnect( querySettings?: ReactReduxFirebaseQueries | ReactReduxFirebaseQueriesFunction @@ -866,8 +902,8 @@ export function useFirebaseConnect( * React hook that return firestore object. * Firestore instance is gathered from `store.firestore`, which is attached * to store by the store enhancer (`reduxFirestore`) during setup of - * [`redux-firestore`](https://github.com/prescottprue/redux-firestore) - * @see https://react-redux-firebase.com/api/useFirestore.html + * [`redux-firestore`](https://github.com/prescottprue/redux-firestore). + * @see https://react-redux-firebase.com/docs/api/useFirestore.html */ export function useFirestore(): ExtendedFirestoreInstance @@ -877,6 +913,7 @@ export function useFirestore(): ExtendedFirestoreInstance * Cloud Firestore, including it's reducer, before attempting to use. * @param queriesConfig - An object or string for paths to sync * from firestore. Can also be a function that returns the object or string. + * @see https://react-redux-firebase.com/docs/api/useFirestoreConnect.html */ export function useFirestoreConnect( queriesConfig?: @@ -895,7 +932,7 @@ export function useFirestoreConnect( * @param path - Path of parameter to load * @param populates - Array of populate config objects * @param notSetValue - Value to return if value is not found - * @see https://react-redux-firebase.com/populate.html + * @see https://react-redux-firebase.com/docs/populate.html */ export function populate( state: object, @@ -907,7 +944,7 @@ export function populate( /** * React Context provider for Firebase instance (with methods wrapped in dispatch). * Needed to use HOCs like firebaseConnect and withFirebase. - * @see https://react-redux-firebase.com/api/ReactReduxFirebaseProvider.html + * @see https://react-redux-firebase.com/docs/api/ReactReduxFirebaseProvider.html */ export function ReactReduxFirebaseProvider( props: ReactReduxFirebaseProviderProps @@ -915,7 +952,7 @@ export function ReactReduxFirebaseProvider( /** * Props passed to ReactReduxFirebaseContext component - * @see https://react-redux-firebase.com/api/ReactReduxFirebaseProvider.html + * @see https://react-redux-firebase.com/docs/api/ReactReduxFirebaseProvider.html */ export interface ReactReduxFirebaseProviderProps { firebase: any @@ -959,6 +996,10 @@ interface ReactReduxFirebaseConfig { useFirestoreForProfile?: boolean } +/** + * Configuration for redux-firestore + * @see https://github.com/prescottprue/redux-firestore#config-options + */ export interface ReduxFirestoreConfig { enableLogging: boolean @@ -996,7 +1037,7 @@ export interface ReduxFirestoreConfig { /** * Props passed to ReactReduFirebaseProvider - * @see https://react-redux-firebase.com/api/ReactReduxFirebaseProvider.html + * @see https://react-redux-firebase.com/docs/api/ReactReduxFirebaseProvider.html */ export interface ReduxFirestoreProviderProps { firebase: any @@ -1014,13 +1055,13 @@ export interface ReduxFirestoreProviderProps { /** * React Context provider for Firestore instance (with methods wrapped in dispatch). Needed to use HOCs * like firestoreConnect and withFirestore. - * @see https://react-redux-firebase.com/api/ReactReduxFirebaseProvider.html + * @see https://react-redux-firebase.com/docs/api/ReactReduxFirebaseProvider.html */ export function ReduxFirestoreProvider(props: ReduxFirestoreProviderProps): any /** * React Higher Order Component that passes firebase as a prop (comes from context.store.firebase). - * @see https://react-redux-firebase.com/api/withFirebase.html + * @see https://react-redux-firebase.com/docs/api/withFirebase.html */ export function withFirebase

( componentToWrap: React.ComponentType

@@ -1028,7 +1069,7 @@ export function withFirebase

( /** * React Higher Order Component that passes firestore as a prop (comes from context.store.firestore) - * @see https://react-redux-firebase.com/api/withFirestore.html + * @see https://react-redux-firebase.com/docs/api/withFirestore.html */ export function withFirestore

( componentToWrap: React.ComponentType

@@ -1042,8 +1083,10 @@ export namespace createFirebaseConnect { const prototype: {} } -// Your Firebase/Firestore user profile object type -// https://react-redux-firebase.com/recipes/profile.html +/** + * Firebase/Firestore user profile object type + * @see https://react-redux-firebase.com/recipes/profile.html + */ export type ProfileType = {} export interface Listeners { diff --git a/package-lock.json b/package-lock.json index 869d47db6..5396bf72e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "react-redux-firebase", - "version": "3.0.1", + "version": "3.0.2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index fc989a1db..c3ac0ee10 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-redux-firebase", - "version": "3.0.1", + "version": "3.0.2", "description": "Redux integration for Firebase. Comes with a Higher Order Components for use with React.", "main": "lib/index.js", "module": "es/index.js", diff --git a/src/ReactReduxFirebaseContext.js b/src/ReactReduxFirebaseContext.js index 88a0d4b66..de43eed8d 100644 --- a/src/ReactReduxFirebaseContext.js +++ b/src/ReactReduxFirebaseContext.js @@ -1,7 +1,7 @@ import { createContext } from 'react' /** - * Context for extended firebase instance created + * @description Context for extended firebase instance created * by react-redux-firebase */ const ReactReduxFirebaseContext = createContext(null) diff --git a/src/ReactReduxFirebaseProvider.js b/src/ReactReduxFirebaseProvider.js index 458b3ea64..8e30d4b51 100644 --- a/src/ReactReduxFirebaseProvider.js +++ b/src/ReactReduxFirebaseProvider.js @@ -5,8 +5,8 @@ import ReactReduxFirebaseContext from './ReactReduxFirebaseContext' import ReduxFirestoreProvider from './ReduxFirestoreProvider' /** - * Provider for context containing extended firebase instance created - * by react-redux-firebase + * @description Provider for context containing extended firebase + * instance created by react-redux-firebase. * @param {object} props - Component props * @param {object} props.config - react-redux-firebase config * @param {Function} props.dispatch - Redux's dispatch function @@ -15,7 +15,7 @@ import ReduxFirestoreProvider from './ReduxFirestoreProvider' * @param {Function} props.createFirestoreInstance - Function for creating * extended firestore instance * @returns {React.Context.Provider} Provider for react-redux-firebase context - * @see https://react-redux-firebase.com/api/ReactReduxFirebaseProvider.html + * @see https://react-redux-firebase.com/api/docs/ReactReduxFirebaseProvider.html */ function ReactReduxFirebaseProvider(props = {}) { const { diff --git a/src/ReduxFirestoreContext.js b/src/ReduxFirestoreContext.js index e8cc01f74..de2629686 100644 --- a/src/ReduxFirestoreContext.js +++ b/src/ReduxFirestoreContext.js @@ -1,7 +1,7 @@ import { createContext } from 'react' /** - * Context for extended firebase instance created + * @description Context for extended firebase instance created * by react-redux-firebase */ const ReduxFirestoreContext = createContext(null) diff --git a/src/ReduxFirestoreProvider.js b/src/ReduxFirestoreProvider.js index 41386c909..24c93b020 100644 --- a/src/ReduxFirestoreProvider.js +++ b/src/ReduxFirestoreProvider.js @@ -4,7 +4,7 @@ import ReduxFirestoreContext from './ReduxFirestoreContext' import createFirebaseInstance from './createFirebaseInstance' /** - * Provider for context containing extended firestore instance created + * @description Provider for context containing extended firestore instance created * by react-redux-firebase * @param {object} props - Component props * @param {object} props.config - react-redux-firebase config @@ -14,7 +14,7 @@ import createFirebaseInstance from './createFirebaseInstance' * @param {Function} props.createFirestoreInstance - Function for creating * extended firestore instance * @returns {React.Context.Provider} Provider for redux-firestore context - * @see https://react-redux-firebase.com/api/ReduxFirestoreProvider.html + * @see https://react-redux-firebase.com/docs/api/ReduxFirestoreProvider.html */ function ReduxFirestoreProvider(props = {}) { const { diff --git a/src/createFirebaseInstance.js b/src/createFirebaseInstance.js index 8e3eff032..2182c3ff1 100644 --- a/src/createFirebaseInstance.js +++ b/src/createFirebaseInstance.js @@ -70,14 +70,13 @@ export default function createFirebaseInstance(firebase, configs, dispatch) { } /** - * Sets data to Firebase. More info available in - * [the docs](https://react-redux-firebase.com/api/props-firebase.html#set). + * Sets data to Firebase. * @param {string} path - Path to location on Firebase which to set * @param {object|string|boolean|number} value - Value to write to Firebase * @param {Function} onComplete - Function to run on complete (`not required`) * @returns {Promise} Containing reference snapshot * @example Basic - * @see https://react-redux-firebase.com/api/firebaseInstance.html#set + * @see https://react-redux-firebase.com/docs/api/firebaseInstance.html#set * import React, { Component } from 'react' * import PropTypes from 'prop-types' * import { firebaseConnect } from 'react-redux-firebase' @@ -100,22 +99,23 @@ export default function createFirebaseInstance(firebase, configs, dispatch) { * Sets data to Firebase along with meta data. Currently, * this includes createdAt and createdBy. *Warning* using this function * may have unintented consequences (setting createdAt even if data already - * exists). More info available in [the docs](https://react-redux-firebase.com/api/props-firebase.html#update). + * exists). * @param {string} path - Path to location on Firebase which to set * @param {object|string|boolean|number} value - Value to write to Firebase * @param {Function} onComplete - Function to run on complete (`not required`) * @returns {Promise} Containing reference snapshot + * @see https://react-redux-firebase.com/docs/api/firebaseInstance.html#update */ const setWithMeta = (path, value, onComplete) => withMeta('set', path, value, onComplete) /** - * Pushes data to Firebase. More info - * available in [the docs](https://react-redux-firebase.com/api/props-firebase.html#push). + * Pushes data to Firebase. * @param {string} path - Path to location on Firebase which to push * @param {object|string|boolean|number} value - Value to push to Firebase * @param {Function} onComplete - Function to run on complete (`not required`) * @returns {Promise} Containing reference snapshot + * @see https://react-redux-firebase.com/docs/api/firebaseInstance.html#push * @example Basic * import React from 'react' * import PropTypes from 'prop-types' @@ -138,19 +138,19 @@ export default function createFirebaseInstance(firebase, configs, dispatch) { /** * Pushes data to Firebase along with meta data. Currently, - * this includes createdAt and createdBy. More info - * available in [the docs](https://react-redux-firebase.com/api/props-firebase.html#pushWithMeta). + * this includes createdAt and createdBy. * @param {string} path - Path to location on Firebase which to set * @param {object|string|boolean|number} value - Value to write to Firebase * @param {Function} onComplete - Function to run on complete (`not required`) * @returns {Promise} Containing reference snapshot + * @see https://react-redux-firebase.com/docs/api/firebaseInstance.html#pushwithmeta */ const pushWithMeta = (path, value, onComplete) => withMeta('push', path, value, onComplete) /** * Updates data on Firebase and sends new data. More info - * available in [the docs](https://react-redux-firebase.com/api/props-firebase.html#update). + * available in [the docs](https://react-redux-firebase.com/docs/api/firebaseInstance.html#update). * @param {string} path - Path to location on Firebase which to update * @param {object|string|boolean|number} value - Value to update to Firebase * @param {Function} onComplete - Function to run on complete (`not required`) @@ -182,12 +182,12 @@ export default function createFirebaseInstance(firebase, configs, dispatch) { /** * Updates data on Firebase along with meta. *Warning* * using this function may have unintented consequences (setting - * createdAt even if data already exists). More info available - * in [the docs](https://react-redux-firebase.com/api/props-firebase.html#updateWithMeta). + * createdAt even if data already exists). * @param {string} path - Path to location on Firebase which to update * @param {object|string|boolean|number} value - Value to update to Firebase * @param {Function} onComplete - Function to run on complete (`not required`) * @returns {Promise} Containing reference snapshot + * @see https://react-redux-firebase.com/docs/api/firebaseInstance.html#updatewithmeta */ const updateWithMeta = (path, value, onComplete) => withMeta('update', path, value, onComplete) @@ -197,11 +197,11 @@ export default function createFirebaseInstance(firebase, configs, dispatch) { * seperate action is not dispatched unless `dispatchRemoveAction: true` is * provided to config on store creation. That means that a listener must * be attached in order for state to be updated when calling remove. - * More info available in [the docs](https://react-redux-firebase.com/api/props-firebase.html#remove). * @param {string} path - Path to location on Firebase which to remove * @param {Function} onComplete - Function to run on complete (`not required`) * @param {Function} options - Options object * @returns {Promise} Containing reference snapshot + * @see https://react-redux-firebase.com/docs/api/firebaseInstance.html#remove * @example Basic * import React from 'react' * import PropTypes from 'prop-types' @@ -226,11 +226,11 @@ export default function createFirebaseInstance(firebase, configs, dispatch) { * Sets data to Firebase only if the path does not already * exist, otherwise it rejects. Internally uses a Firebase transaction to * prevent a race condition between seperate clients calling uniqueSet. - * More info available in [the docs](https://react-redux-firebase.com/api/props-firebase.html#uniqueSet). * @param {string} path - Path to location on Firebase which to set * @param {object|string|boolean|number} value - Value to write to Firebase * @param {Function} onComplete - Function to run on complete (`not required`) * @returns {Promise} Containing reference snapshot + * @see https://react-redux-firebase.com/docs/api/firebaseInstance.html#uniqueset * @example Basic * import React, { Component } from 'react' * import PropTypes from 'prop-types' @@ -263,7 +263,7 @@ export default function createFirebaseInstance(firebase, configs, dispatch) { /** * Upload a file to Firebase Storage with the option to store * its metadata in Firebase Database. More info available - * in [the docs](https://react-redux-firebase.com/api/props-firebase.html#uploadFile). + * in [the docs](). * @param {string} path - Path to location on Firebase which to set * @param {File} file - File object to upload (usually first element from * array output of select-file or a drag/drop `onDrop`) @@ -273,6 +273,7 @@ export default function createFirebaseInstance(firebase, configs, dispatch) { * @param {object} options.metdata - Metadata for the file (passed as second * argument to storage.put calls) * @returns {Promise} Containing the File object + * @see https://react-redux-firebase.com/docs/api/firebaseInstance.html#uploadfile */ const uploadFile = (path, file, dbPath, options) => storageActions.uploadFile(dispatch, firebase, { @@ -284,8 +285,7 @@ export default function createFirebaseInstance(firebase, configs, dispatch) { /** * Upload multiple files to Firebase Storage with the option - * to store their metadata in Firebase Database. More info available - * in [the docs](https://react-redux-firebase.com/api/props-firebase.html#uploadFiles). + * to store their metadata in Firebase Database. * @param {string} path - Path to location on Firebase which to set * @param {Array} files - Array of File objects to upload (usually from * a select-file or a drag/drop `onDrop`) @@ -293,6 +293,7 @@ export default function createFirebaseInstance(firebase, configs, dispatch) { * @param {object} options - Options * @param {string} options.name - Name of the file * @returns {Promise} Containing an array of File objects + * @see https://react-redux-firebase.com/docs/api/firebaseInstance.html#uploadfiles */ const uploadFiles = (path, files, dbPath, options) => storageActions.uploadFiles(dispatch, firebase, { @@ -304,11 +305,11 @@ export default function createFirebaseInstance(firebase, configs, dispatch) { /** * Delete a file from Firebase Storage with the option to - * remove its metadata in Firebase Database. More info available - * in [the docs](https://react-redux-firebase.com/api/props-firebase.html#deleteFile). + * remove its metadata in Firebase Database. * @param {string} path - Path to location on Firebase which to set * @param {string} dbPath - Database path to place uploaded file metadata * @returns {Promise} Containing the File object + * @see https://react-redux-firebase.com/docs/api/firebaseInstance.html#deletefile */ const deleteFile = (path, dbPath) => storageActions.deleteFile(dispatch, firebase, { path, dbPath }) @@ -316,7 +317,6 @@ export default function createFirebaseInstance(firebase, configs, dispatch) { /** * Watch event. **Note:** this method is used internally * so examples have not yet been created, and it may not work as expected. - * More info available in [the docs](https://react-redux-firebase.com/api/props-firebase.html#watchEvent). * @param {string} type - Type of watch event * @param {string} path - Path to location on Firebase which to set listener * @param {string} storeAs - Name of listener results within redux store @@ -324,6 +324,7 @@ export default function createFirebaseInstance(firebase, configs, dispatch) { * @param {Array} options.queryParams - List of parameters for the query * @param {string} options.queryId - id of the query * @returns {Promise|void} Results of calling watch event + * @see https://react-redux-firebase.com/docs/api/firebaseInstance.html#watchevent */ const watchEvent = (type, path, storeAs, options = {}) => queryActions.watchEvent(firebase, dispatch, { @@ -336,12 +337,13 @@ export default function createFirebaseInstance(firebase, configs, dispatch) { /** * Unset a listener watch event. **Note:** this method is used * internally so examples have not yet been created, and it may not work - * as expected. More info available in [the docs](https://react-redux-firebase.com/api/props-firebase.html#unwatchevent). + * as expected. * @param {string} type - Type of watch event * @param {string} path - Path to location on Firebase which to unset listener * @param {string} queryId - Id of the listener * @param {object} options - Event options object * @returns {void} + * @see https://react-redux-firebase.com/docs/api/firebaseInstance.html#unwatchevent */ const unWatchEvent = (type, path, queryId, options = {}) => queryActions.unWatchEvent(firebase, dispatch, { @@ -378,7 +380,8 @@ export default function createFirebaseInstance(firebase, configs, dispatch) { /** * Logs user into Firebase. For examples, visit the - * [auth section of the docs](/docs/auth.md) + * [auth section of the docs](https://react-redux-firebase.com/docs/auth.html) or the + * [auth recipes section](https://react-redux-firebase.com/docs/recipes/auth.html). * @param {object} credentials - Credentials for authenticating * @param {string} credentials.provider - External provider (google | * facebook | twitter) @@ -387,6 +390,8 @@ export default function createFirebaseInstance(firebase, configs, dispatch) { * @param {string} credentials.email - Credentials for authenticating * @param {string} credentials.password - Credentials for authenticating (only used with email) * @returns {Promise} Containing user's auth data + * @see https://react-redux-firebase.com/docs/auth.html#logincredentials + * @see https://react-redux-firebase.com/docs/api/firebaseInstance.html#login */ const login = credentials => authActions.login(dispatch, firebase, credentials) @@ -404,6 +409,7 @@ export default function createFirebaseInstance(firebase, configs, dispatch) { * Logs user out of Firebase and empties firebase state from * redux store * @returns {Promise} Resolves after logout is complete + * @see https://react-redux-firebase.com/docs/auth.html#logout */ const logout = () => authActions.logout(dispatch, firebase) @@ -416,6 +422,7 @@ export default function createFirebaseInstance(firebase, configs, dispatch) { * @param {string} credentials.password - Credentials for authenticating (only used with email) * @param {object} profile - Data to include within new user profile * @returns {Promise} Containing user's auth data + * @see https://react-redux-firebase.com/docs/auth.html#createuser */ const createUser = (credentials, profile) => authActions.createUser(dispatch, firebase, credentials, profile) @@ -425,6 +432,7 @@ export default function createFirebaseInstance(firebase, configs, dispatch) { * @param {object} credentials - Credentials for authenticating * @param {string} credentials.email - Credentials for authenticating * @returns {Promise} Resolves after password reset email is sent + * @see https://react-redux-firebase.com/docs/api/firebaseInstance.html#resetpassword */ const resetPassword = credentials => authActions.resetPassword(dispatch, firebase, credentials) @@ -434,6 +442,7 @@ export default function createFirebaseInstance(firebase, configs, dispatch) { * @param {string} code - Password reset code to verify * @param {string} password - New Password to confirm reset to * @returns {Promise} Resolves after password reset is confirmed + * @see https://react-redux-firebase.com/docs/api/firebaseInstance.html#confirmpasswordreset */ const confirmPasswordReset = (code, password) => authActions.confirmPasswordReset(dispatch, firebase, code, password) @@ -443,6 +452,7 @@ export default function createFirebaseInstance(firebase, configs, dispatch) { * email is valid * @param {string} code - Password reset code to verify * @returns {Promise} Containing user auth info + * @see https://react-redux-firebase.com/docs/api/firebaseInstance.html#verifypasswordreset */ const verifyPasswordResetCode = code => authActions.verifyPasswordResetCode(dispatch, firebase, code) @@ -461,6 +471,7 @@ export default function createFirebaseInstance(firebase, configs, dispatch) { * @param {boolean} [options.merge=true] - Whether or not to use merge when * setting profile. Note: Only used when updating profile on Firestore * @returns {Promise} Returns after updating profile within database + * @see https://react-redux-firebase.com/docs/api/firebaseInstance.html#updateprofile */ const updateProfile = (profileUpdate, options) => authActions.updateProfile(dispatch, firebase, profileUpdate, options) @@ -470,6 +481,7 @@ export default function createFirebaseInstance(firebase, configs, dispatch) { * @param {object} authUpdate - Update to be auth object * @param {boolean} updateInProfile - Update in profile * @returns {Promise} Returns after updating auth profile + * @see https://react-redux-firebase.com/docs/api/firebaseInstance.html#updateauth */ const updateAuth = (authUpdate, updateInProfile) => authActions.updateAuth(dispatch, firebase, authUpdate, updateInProfile) @@ -479,6 +491,7 @@ export default function createFirebaseInstance(firebase, configs, dispatch) { * @param {string} newEmail - Update to be auth object * @param {boolean} updateInProfile - Update in profile * @returns {Promise} Resolves after email is updated in user's auth + * @see https://react-redux-firebase.com/docs/api/firebaseInstance.html#updateemail */ const updateEmail = (newEmail, updateInProfile) => authActions.updateEmail(dispatch, firebase, newEmail, updateInProfile) @@ -486,6 +499,7 @@ export default function createFirebaseInstance(firebase, configs, dispatch) { /** * Reload user's auth object. Must be authenticated. * @returns {Promise} Resolves after reloading firebase auth + * @see https://react-redux-firebase.com/docs/api/firebaseInstance.html#reloadauth */ const reloadAuth = () => authActions.reloadAuth(dispatch, firebase) @@ -493,6 +507,7 @@ export default function createFirebaseInstance(firebase, configs, dispatch) { * Links the user account with the given credentials. * @param {firebase.auth.AuthCredential} credential - The auth credential * @returns {Promise} Resolves after linking auth with a credential + * @see https://react-redux-firebase.com/docs/api/firebaseInstance.html#linkwithcredential */ const linkWithCredential = credential => authActions.linkWithCredential(dispatch, firebase, credential) @@ -505,6 +520,7 @@ export default function createFirebaseInstance(firebase, configs, dispatch) { * authenticates and does profile handling. * @param {firebase.auth.ConfirmationResult} credential - The auth credential * @returns {Promise} + * @see https://react-redux-firebase.com/docs/api/firebaseInstance.html#signinwithphonenumber */ /** diff --git a/src/firebaseConnect.js b/src/firebaseConnect.js index 0629b71e7..b68264a44 100644 --- a/src/firebaseConnect.js +++ b/src/firebaseConnect.js @@ -8,14 +8,14 @@ import ReactReduxFirebaseContext from './ReactReduxFirebaseContext' /** * @augments React.Component - * React Higher Order Component that automatically listens/unListens to + * @description React Higher Order Component that automatically listens/unListens to * Firebase Real Time Database on mount/unmount of the component. This uses * React's Component Lifecycle hooks. * @param {Array|Function} queriesConfig - Array of objects or strings for paths to sync * from Firebase. Can also be a function that returns the array. The function * is passed the current props and the firebase object. * @returns {Function} - that accepts a component to wrap and returns the wrapped component - * @see http://react-redux-firebase.com/api/firebaseConnect.html + * @see https://react-redux-firebase.com/docs/api/firebaseConnect.html * @example Basic * // props.firebase set on App component as firebase object with helpers * import { firebaseConnect } from 'react-redux-firebase' diff --git a/src/firestoreConnect.js b/src/firestoreConnect.js index 08e207aa4..f01ef06a6 100644 --- a/src/firestoreConnect.js +++ b/src/firestoreConnect.js @@ -8,7 +8,7 @@ import ReactReduxFirebaseContext from './ReactReduxFirebaseContext' /** * @augments React.Component - * Higher Order Component that automatically listens/unListens + * @description Higher Order Component that automatically listens/unListens * to provided Cloud Firestore paths using React's Lifecycle hooks. Make sure you * have required/imported Cloud Firestore, including it's reducer, before * attempting to use. **Note** Populate is not yet supported. @@ -17,7 +17,7 @@ import ReactReduxFirebaseContext from './ReactReduxFirebaseContext' * is passed the current props and the firebase object. * @returns {Function} - Function which accepts a component to wrap and returns the * wrapped component - * @see http://react-redux-firebase.com/api/firestoreConnect.html + * @see https://react-redux-firebase.com/docs/api/firestoreConnect.html * @example Basic * // props.firebase set on App component as firebase object with helpers * import { firestoreConnect } from 'react-redux-firebase' diff --git a/src/helpers.js b/src/helpers.js index 268cf5496..856eb89a5 100644 --- a/src/helpers.js +++ b/src/helpers.js @@ -286,7 +286,7 @@ function populateChild(state, child, p) { * // each todo has child 'owner' populated from matching uid in 'users' root * // for loading un-populated todos use state.firebase.data.todos * todos: populate(state.firebase, 'todos', populates), - * }) + * })) * ) * * export default enhance(SomeComponent) diff --git a/src/useFirebase.js b/src/useFirebase.js index afd17605d..a232688ff 100644 --- a/src/useFirebase.js +++ b/src/useFirebase.js @@ -3,14 +3,14 @@ import ReactReduxFirebaseContext from './ReactReduxFirebaseContext' /** * @name useFirebase - * React hook that provides `firebase` object. + * @description React hook that provides `firebase` object. * Firebase is gathered from `store.firebase`, which is attached to store * by the store enhancer (`reactReduxFirebase`) during setup. * **NOTE**: This version of the Firebase library has extra methods, config, * and functionality which give it it's capabilities such as dispatching * actions. * @returns {object} - Extended Firebase instance - * @see https://react-redux-firebase.com/api/useFirebase.html + * @see https://react-redux-firebase.com/docs/api/useFirebase.html * @example Basic * import { useFirebase } from 'react-redux-firebase' * diff --git a/src/useFirebaseConnect.js b/src/useFirebaseConnect.js index 51d62d560..f2fb9e726 100644 --- a/src/useFirebaseConnect.js +++ b/src/useFirebaseConnect.js @@ -5,14 +5,15 @@ import { getEventsFromInput, invokeArrayQuery } from './utils' import useFirebase from './useFirebase' /** - * Hook that automatically listens/unListens to provided firebase paths + * @description Hook that automatically listens/unListens to provided firebase paths * using React's useEffect hook. * @param {object|string|Function|Array} queriesConfig - Object, string, or * array contains object or string for path to sync from Firebase or null if * hook doesn't need to sync. Can also be a function that returns an object, * a path string, or array of an object or a path string. - * @see https://react-redux-firebase.com/api/useFirebaseConnect.html + * @see https://react-redux-firebase.com/docs/api/useFirebaseConnect.html * @example Ordered Data + * import React from 'react' * import { useSelector } from 'react-redux' * import { useFirebaseConnect } from 'react-redux-firebase' * @@ -28,27 +29,27 @@ import useFirebase from './useFirebase' * ) * } * @example Data that depends on props + * import React from 'react' * import { compose } from 'redux' * import { useSelector } from 'react-redux' * import { useFirebaseConnect } from 'react-redux-firebase' * - * function Post({ postId }) { + * export default function Post({ postId }) { * useFirebaseConnect(`posts/${postId}`) // sync /posts/postId from firebase into redux - * const post = useSelector(({ firebase }) => state.firebase.ordered.posts && state.firebase.ordered.posts[postId]) + * const post = useSelector(({ firebase: { ordered: { posts } } }) => posts && posts[postId]) * return ( *

* {JSON.stringify(post, null, 2)} *
* ) * } - * - * export default enhance(Post) * @example Data that depends on props, an array as a query + * import React from 'react' * import { compose } from 'redux' * import { useSelector } from 'react-redux' * import { useFirebaseConnect, getVal } from 'react-redux-firebase' * - * function Post({ post, postId }) { + * export default function Post({ postId }) { * useFirebaseConnect([`posts/${postId}`], [postId]) // sync /posts/postId from firebase into redux * const post = useSelector(state => { * return state.firebase.ordered.posts && state.firebase.ordered.posts[postId] @@ -59,8 +60,6 @@ import useFirebase from './useFirebase' * * ) * } - * - * export default Post */ export default function useFirebaseConnect(queriesConfig) { const firebase = useFirebase() diff --git a/src/useFirestore.js b/src/useFirestore.js index e35900277..c184d1057 100644 --- a/src/useFirestore.js +++ b/src/useFirestore.js @@ -3,17 +3,17 @@ import ReduxFirestoreContext from './ReduxFirestoreContext' /** * @name useFirestore - * React hook that return firestore object. + * @description React hook that return firestore object. * Firestore instance is gathered from `store.firestore`, which is attached * to store by the store enhancer (`reduxFirestore`) during setup of * [`redux-firestore`](https://github.com/prescottprue/redux-firestore) * @returns {object} - Extended Firestore instance - * @see https://react-redux-firebase.com/api/useFirestore.html + * @see https://react-redux-firebase.com/docs/api/useFirestore.html * @example Basic * import React from 'react' * import { useFirestore } from 'react-redux-firebase' * - * function AddData({ firebase: { add } }) { + * export default function AddData({ firebase: { add } }) { * const firestore = useFirestore() * * function addTodo() { @@ -29,8 +29,6 @@ import ReduxFirestoreContext from './ReduxFirestoreContext' * * ) * } - * - * export default AddTodo */ export default function useFirestore() { return useContext(ReduxFirestoreContext) diff --git a/src/useFirestoreConnect.js b/src/useFirestoreConnect.js index 39c5e9690..734393ff6 100644 --- a/src/useFirestoreConnect.js +++ b/src/useFirestoreConnect.js @@ -4,21 +4,21 @@ import { invokeArrayQuery, getChanges } from './utils' import useFirestore from './useFirestore' /** - * React hook that automatically listens/unListens + * @description React hook that automatically listens/unListens * to provided Cloud Firestore paths. Make sure you have required/imported * Cloud Firestore, including it's reducer, before attempting to use. * **Note** Populate is not yet supported. * @param {object|string|Array|Function} queriesConfigs - An object, string, * or array of object or string for paths to sync from firestore. Can also be * a function that returns the object, string, or array of object or string. - * @see https://react-redux-firebase.com/api/useFirestoreConnect.html + * @see https://react-redux-firebase.com/docs/api/useFirestoreConnect.html * @example Basic * import React from 'react' * import { map } from 'lodash' * import { useSelector } from 'react-redux' * import { useFirebaseConnect } from 'react-redux-firebase' * - * function TodosList() { + * export default function TodosList() { * useFirebaseConnect('todos') // sync todos collection from Firestore into redux * const todos = useSelector(state => state.firebase.data.todos) * return ( @@ -29,28 +29,21 @@ import useFirestore from './useFirestore' * * ) * } - * export default TodosList * @example Object as query * import React, { useMemo } from 'react' * import { get } from 'lodash' * import { connect } from 'react-redux' * import { useFirebaseConnect } from 'react-redux-firebase' * - * function TodoItem({ todoId, todoData }) { + * export default function TodoItem({ todoId }) { * useFirebaseConnect(() => ({ * collection: 'todos', * doc: todoId - * }), [todoId]) // include dependency in the hook + * })) + * const todo = useSelector(({ firebase: { data } }) => data.todos && data.todos[todoId]) * * return
{JSON.stringify(todoData)}
* } - * - * // pass todo data from redux as props.todosList - * export default compose( - * connect((state) => ({ - * todoData: get(state, ['firestore', 'data', 'todos', todoId]) - * }) - * )(TodoItem) */ export default function useFirestoreConnect(queriesConfigs) { const firestore = useFirestore() diff --git a/src/withFirebase.js b/src/withFirebase.js index 775078bb0..48203d759 100644 --- a/src/withFirebase.js +++ b/src/withFirebase.js @@ -5,7 +5,7 @@ import ReactReduxFirebaseContext from './ReactReduxFirebaseContext' /** * @augments React.Component - * Higher Order Component that provides `firebase` and + * @description Higher Order Component that provides `firebase` and * `dispatch` as a props to React Components. Firebase is gathered from * `store.firebase`, which is attached to store by the store enhancer * (`reactReduxFirebase`) during setup. @@ -15,7 +15,7 @@ import ReactReduxFirebaseContext from './ReactReduxFirebaseContext' * @param {React.Component} WrappedComponent - React component to wrap * @returns {Function} - Which accepts a component to wrap and returns the * wrapped component - * @see http://react-redux-firebase.com/api/withFirebase.html + * @see http://react-redux-firebase.com/docs/api/withFirebase.html * @example Basic * import React from 'react' * import { withFirebase } from 'react-redux-firebase' diff --git a/src/withFirestore.js b/src/withFirestore.js index 9b62bd630..ea5912509 100644 --- a/src/withFirestore.js +++ b/src/withFirestore.js @@ -6,7 +6,7 @@ import ReduxFirestoreContext from './ReduxFirestoreContext' /** * @augments React.Component - * Higher Order Component that attaches `firestore`, `firebase` + * @description Higher Order Component that attaches `firestore`, `firebase` * and `dispatch` as props to React Components. Firebase instance is gathered * from `store.firestore`, which is attached to store by the store enhancer * (`reduxFirestore`) during setup of @@ -14,7 +14,7 @@ import ReduxFirestoreContext from './ReduxFirestoreContext' * @param {React.Component} WrappedComponent - React component to wrap * @returns {Function} - Which accepts a component to wrap and returns the * wrapped component - * @see http://react-redux-firebase.com/api/withFirestore.html + * @see http://react-redux-firebase.com/docs/api/withFirestore.html * @example Basic * import React from 'react' * import { withFirestore } from 'react-redux-firebase'