useBackend()
Home > @gooddata/sdk-ui > useBackend
useBackend() function
Hook to get analytical backend instance provided to BackendProvider.
Signature:
useBackend: (backend?: IAnalyticalBackend) => IAnalyticalBackend | undefined
Parameters
Parameter | Type | Description |
---|---|---|
backend | IAnalyticalBackend | (Optional) backend to use instead of context value. If undefined, the context value is used. |
Returns:
IAnalyticalBackend | undefined
Remarks
You can set a backend override that will be returned if defined. This makes the usage more ergonomic (see the following example).
Note: For a better TypeScript experience without the hassle of undefined values, you can use the useBackendStrict() hook.
Example
// instead of
const fromContext = useBackend();
const effectiveBackend = fromArguments ?? fromContext.
// you can write
const backend = useBackend(fromArguments);