react-query-firebase / react-native/firestore / useGetRealtimeDocData
Function: useGetRealtimeDocData()
ts
function useGetRealtimeDocData<AppModelType>(options): object;
Defined in: react-native/firestore/useGetRealtimeDocData.ts:64
A hook to get realtime updates to a firestore document.
Type Parameters
AppModelType
AppModelType
extends AppModel
= AppModel
Parameters
options
onError?
(error
) => unknown
A callback to be called if the listen fails or is cancelled. No further callbacks will occur.
path?
string
A slash-separated path to a document. Has to be omitted to use
pathSegments?
string
[]
Additional path segments that will be applied relative to the first argument.
reference?
DocumentReference
<AppModelType
>
A reference to a collection.
Returns
object
data
ts
data: null | AppModelType;
error
ts
error: null | Error | NativeFirebaseError;
isError
ts
isError: boolean;
isFetching
ts
isFetching: boolean;
Example
jsx
const firebaseConfig = {};
export const MyComponent = () => {
const result = useGetRealtimeDocData('collection/documentId');
return (
<div>
{JSON.stringify(result)}
</div>
);
};