useWorkspaceStrict()
Home > @gooddata/sdk-ui > useWorkspaceStrict
useWorkspaceStrict() function
Hook to get workspace instance provided to WorkspaceProvider.
Signature:
useWorkspaceStrict: (workspace?: string, context?: string) => string
Parameters
Parameter | Type | Description |
---|---|---|
workspace | string | (Optional) workspace to use instead of context value. If undefined, the context value is used. |
context | string | (Optional) provide context to improve error message in raised invariant (e.g. parent hook name). |
Returns:
string
Remarks
You can set a workspace override that will be returned if defined. This makes the usage more ergonomic (see the following example).
Note: Note: If you do not provide a workspace identifier to WorkspaceProvider or as a parameter for this hook, an invariant error is raised.
Example
// instead of
const fromContext = useWorkspaceStrict();
const effectiveWorkspace = fromArguments ?? fromContext.
// you can write
const workspace = useWorkspaceStrict(fromArguments);