@medplum/react-hooks
Advanced tools
Comparing version 2.1.14 to 2.1.15
@@ -10,3 +10,3 @@ /// <reference types="react" /> | ||
import { QueryTypes } from '@medplum/core'; | ||
import { default as React_2 } from 'react'; | ||
import { ReactNode } from 'react'; | ||
import { Reference } from '@medplum/fhirtypes'; | ||
@@ -38,3 +38,3 @@ import { Resource } from '@medplum/fhirtypes'; | ||
navigate?: MepdlumNavigateFunction; | ||
children: React_2.ReactNode; | ||
children: ReactNode; | ||
} | ||
@@ -41,0 +41,0 @@ |
{ | ||
"name": "@medplum/react-hooks", | ||
"version": "2.1.14", | ||
"version": "2.1.15", | ||
"description": "Medplum React Hooks Library", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -59,2 +59,29 @@ # Medplum React Hooks Library | ||
## `useMedplumContext` | ||
`useMedplumContext` can be used to access the `MedplumContext` provided by the `MedplumProvider` directly. The `MedplumContext` has the following interface: | ||
```ts | ||
interface MedplumContext { | ||
medplum: MedplumClient; | ||
navigate: MepdlumNavigateFunction; | ||
profile?: ProfileResource; | ||
loading: boolean; | ||
} | ||
``` | ||
### Using `loading` to know when `MedplumClient` initialization is done | ||
You can use the `loading` property from `useMedplumContext()` to know when `MedplumClient` has finished initialization successfully. `loading` is updated asynchronously so it will usually start as `false` and change to `true` once the client has finished its initialization. | ||
```tsx | ||
function MyComponent(): JSX.Element { | ||
const { loading } = useMedplumContext(); | ||
return loading ? ( | ||
<Spinner /> | ||
) : ( | ||
<div>Loaded!</div> | ||
); | ||
} | ||
``` | ||
## About Medplum | ||
@@ -61,0 +88,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
40996
124
93