useBackend
Home > @gooddata/sdk-ui > useBackend
useBackend variable
Hook to get analytical backend instance provided to BackendProvider.
Signature:
useBackend: (backend?: IAnalyticalBackend) => 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);