Hooks
useActivePageKeyFromUrl
Hook returning the active dashboard page key from the URL, if any. Defaults to the first page specified in the dashboard state.
useActivePageKeyFromUrl()
Returns:
string | undefined
useActivity
React hook returning:
-
the value for the given activity key
-
a function to update this value
-
whether the activity is loading
useActivity(key)
| Argument | Type | Description |
|---|---|---|
| key | T |
Returns:
[Activity[T] | null, (value: Activity[T]) => void, { isLoading: boolean; }]
useAtotiClient
React hook returning the AtotiClient at serverKey.
useAtotiClient(serverKey)
| Argument | Type | Description |
|---|---|---|
| serverKey | string | undefined |
Returns:
AtotiClient | undefined
Throws:
ClientsNotFoundError when no clients are provided via ClientsProvider.
AtotiClientNotFoundError when serverKey is defined but no AtotiClient is provided for this key via ClientsProvider.
useAtotiClients
React hook returning the map of all registered AtotiClients.
useAtotiClients()
Returns:
{ [serverKey: string]: AtotiClient; }
useConnectionStatuses
React hook returning the overall status of the connection with the registered Atoti clients.
useConnectionStatuses()
Returns:
{ [serverKey: string]: ConnectionStatus; }
useContentClient
React hook returning the ContentClient.
useContentClient(options)
| Argument | Type | Description |
|---|---|---|
| options | { throwIfMissing: boolean; } |
Returns:
ContentClient<Settings> | undefined
Throws:
ClientsNotFoundError when no clients are provided via ClientsProvider, unless throwIfMissing is set to false.
ContentClientNotFoundError when no ContentClient is provided via ClientsProvider, unless throwIfMissing is set to false.
useCube
React hook returning a cube. Defaults serverKey to the key of the first provided server, when props.widgetState.serverKey is not defined. Defaults cube to the first cube of the target server, when props.widgetState.query.mdx does not include a cube name and no widgetState.initialCubeName is defined.
useCube(widgetState)
| Argument | Type | Description |
|---|---|---|
| widgetState | T |
Returns:
{ cube: Cube; dataModel: DataModel; serverKey: string; }
Throws:
- DataModelNotFoundError if the data model is not loaded yet. - CubeNotFoundError if the data model does not contain any cube with the specified name. - EmptyDataModelError if the data model was loaded but does not contain any cube.