useExecutionDataView
Fetch execution data as a DataViewFacade from a prepared execution or inline seriesBy/slicesBy configuration.
React hook to get data for a specific execution. Use it for ad-hoc executions; to load the data of a saved visualization, use useInsightDataView.
Accepts either a prepared execution or an execution configuration with measures, attributes, filters, and sorting. Returns a DataViewFacade wrapping the execution result.
Basic usage
import { useExecutionDataView } from "@gooddata/sdk-ui";
import * as Md from "./catalog.js";
function MyDataComponent() {
const { result, status, error } = useExecutionDataView({
execution: {
seriesBy: [Md.Revenue, Md.Region],
slicesBy: [Md.DateMonth],
filters: [],
},
});
if (status === "loading" || status === "pending") {
return <div>Loading...</div>;
}
if (status === "error") {
return <div>Error: {error?.message}</div>;
}
// result is a DataViewFacade
const data = result?.data().slices().toArray();
// ...
}
Parameters
| Property | Type | Description |
|---|---|---|
execution | IPreparedExecution | IExecutionConfiguration | Either a prepared execution or inline config with seriesBy, slicesBy, etc. |
execution.seriesBy | AttributesMeasuresOrPlaceholders | Measures and scoping attributes for data series. |
execution.slicesBy | AttributesOrPlaceholders | Attributes to slice data series by. |
execution.filters | NullableFiltersOrPlaceholders | Server-side filters. |
execution.sortBy | SortsOrPlaceholders | Server-side sorting. |
window | DataViewWindow | Load only a specific window of data (for paging). |
backend | IAnalyticalBackend | Backend override (defaults to BackendProvider context). |
workspace | string | Workspace override (defaults to WorkspaceProvider context). |
Return value
UseCancelablePromiseState<DataViewFacade, GoodDataSdkError>, the same shape as useCancelablePromise returns.
| Field | Type | Description |
|---|---|---|
status | "pending" | "loading" | "success" | "error" | Current state of the load. |
result | DataViewFacade | undefined | The loaded data view. Set only in the "success" state. |
error | GoodDataSdkError | undefined | The error. Set only in the "error" state. |
States
status | result | error | When |
|---|---|---|---|
"pending" | undefined | undefined | execution is not provided. |
"loading" | undefined | undefined | The execution is running or its data is being read. |
"success" | DataViewFacade | undefined | The data view for window (or all data when window is not set) was read. |
"error" | undefined | GoodDataSdkError | The execution or data read failed. The error is converted to a GoodDataSdkError subtype. |
When it re-runs
The hook starts a new load when any of these change:
backendorworkspace(the effective values, including context values).backendis compared by reference,workspaceby value.- The fingerprint of the prepared execution. An inline
executionconfiguration is compared by its content, not by object identity. window.offsetorwindow.size, compared by reference.enableExecutionCancelling.- Any item in the optional second argument,
deps.
When a load is superseded or the component unmounts before it finishes, its result is ignored and onCancel is called. The request itself keeps running unless enableExecutionCancelling is true; then the hook aborts the execution’s signal and the request is canceled.
Notes
- Without a
backendprop or aBackendProvider, the hook throws: “useExecutionDataView: IAnalyticalBackend must be defined. Either pass it as a parameter or make sure there is a BackendProvider up the component tree.” A missing workspace throws the matchingWorkspaceProvidererror. - The
backendandworkspaceprops take precedence over the context values. seriesBy,slicesBy,totals,filters, andsortByin an execution configuration can contain placeholders. PassplaceholdersResolutionContextfor composed placeholders. The object is treated as a configuration only when it hasseriesBy.window.offsetandwindow.sizeare arrays compared by reference. Keep them stable (for example withuseMemo); a new array on every render starts a new load on every render.- Unlike Execute, the hook does not turn a no-data error into an empty result. It returns the
"error"state with the converted error. - The callbacks
onLoading,onPending,onSuccess,onError, andonCancelare passed touseCancelablePromise. Changing them does not start a new load.
Props
| Prop | Type | Required | Description | Inherited from |
|---|---|---|---|---|
backend | IAnalyticalBackend | No | Backend to work with. | — |
enableExecutionCancelling | boolean | No | Optionally enable real execution cancellation. This means that if the execution request is not yet finished and the execution changes, the request will be cancelled and the new execution will be started. Default: false | — |
execution | IPreparedExecution | IExecutionConfiguration | No | Prepared execution, or execution configuration for which you want to get the data view. | — |
window | DataViewWindow | No | You can define only a specific “window” of data to load. | — |
workspace | string | No | Workspace where execution should be executed. | — |
Related
Fetch and render backend data with the Execute component using series, slices, filters, and a render-prop child.
Load a saved visualization by reference and return its execution result as a DataViewFacade with optional filters and sorting.
Understand the hooks, components, and backend API that feed custom visualizations, and how series, slices, and data points structure the result.
Define execution dimensions, totals, and sorting, then read computed data through execution results, data views, and DataViewFacade.
Use useDataExport to run CSV, XLSX, or raw exports from a prepared execution, handle export lifecycle callbacks, and retrieve the download URI.