useWorkspace
Home > @gooddata/sdk-ui > useWorkspace
useWorkspace variable
Hook to get workspace instance provided to WorkspaceProvider.
Signature:
useWorkspace: (workspace?: string | undefined) => string | undefined
Remarks
You can set a workspace 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 useWorkspaceStrict hook.
Example
// instead of
const fromContext = useWorkspace();
const effectiveWorkspace = fromArguments ?? fromContext.
// you can write
const workspace = useWorkspace(fromArguments);