> Documentation index: https://www.gooddata.ai/docs/gooddata-ui/llms.txt lists every page of these docs as Markdown.

# RawExecute

> Run a prepared execution and pass the resulting data view to a render-prop child.

API reference: [RawExecute](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui/sdk-ui.rawexecute/index.md) (variable), [IRawExecuteProps](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui/sdk-ui.irawexecuteprops/index.md) (interface)

The [`RawExecute`](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui/sdk-ui.rawexecute/index.md) component runs an execution that you have already prepared ([`IPreparedExecution`](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.ipreparedexecution/index.md)) and passes the loading state, error, and data view to its `children` render function. Build the prepared execution yourself, for example with `backend.workspace(workspace).execution().forItems([...])`; to run a saved visualization, use [`ExecuteInsight`](https://www.gooddata.ai/docs/gooddata-ui/latest/data-layer/execute-insight/index.md) instead.

## [Basic usage](https://www.gooddata.ai/docs/gooddata-ui/latest/data-layer/raw-execute/#basic-usage)

```tsx
import { RawExecute, useBackendStrict, useWorkspaceStrict } from "@gooddata/sdk-ui";
import * as Md from "./catalog.js";

export const Example = () => {
    const backend = useBackendStrict();
    const workspace = useWorkspaceStrict();
    const execution = backend.workspace(workspace).execution().forItems([Md.Amount, Md.Product.Name]);

    return (
        <RawExecute execution={execution}>
            {({ isLoading, error, result }) => {
                if (isLoading) {
                    return <div>Loading...</div>;
                }
                if (error) {
                    return <div>Error: {error.message}</div>;
                }
                return <pre>{JSON.stringify(result?.dataView.data, null, 2)}</pre>;
            }}
        </RawExecute>
    );
};
```

## [States](https://www.gooddata.ai/docs/gooddata-ui/latest/data-layer/raw-execute/#states)

The `children` function receives a [`WithLoadingResult`](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui/sdk-ui.withloadingresult/index.md) in one of these states.

| `isLoading` | `result` | `error` | When |
|-------------|----------|---------|------|
| `false` | `undefined` | `undefined` | Before the first load starts: on the first render and, when `loadOnMount` is `false`, until you call `reload()` or a prop change triggers a new execution. |
| `true` | `undefined` | `undefined` | The execution is running. |
| `false` | [`DataViewFacade`](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui/sdk-ui.dataviewfacade/index.md) | `undefined` | The data was loaded. An empty result is returned here, not as a [`NoDataError`](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.nodataerror/index.md). |
| `false` | `undefined` | [`GoodDataSdkError`](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui/sdk-ui.gooddatasdkerror/index.md) | The execution or data read failed. |

`reload` is available in every state and starts a new execution.

## [Rendering](https://www.gooddata.ai/docs/gooddata-ui/latest/data-layer/raw-execute/#rendering)

[`RawExecute`](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui/sdk-ui.rawexecute/index.md) picks what to render in this order:

| Condition | Renders |
|-----------|---------|
| [`ErrorComponent`](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui/sdk-ui.errorcomponent/index.md) is set and there is an `error` | [`ErrorComponent`](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui/sdk-ui.errorcomponent/index.md) with the `error` prop. |
| [`LoadingComponent`](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui/sdk-ui.loadingcomponent/index.md) is set and `isLoading` is `true` | [`LoadingComponent`](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui/sdk-ui.loadingcomponent/index.md). |
| Both [`LoadingComponent`](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui/sdk-ui.loadingcomponent/index.md) and [`ErrorComponent`](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui/sdk-ui.errorcomponent/index.md) are set and there is no `result` | Nothing (`null`). |
| Otherwise | The `children` function. |

When you set both [`LoadingComponent`](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui/sdk-ui.loadingcomponent/index.md) and [`ErrorComponent`](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui/sdk-ui.errorcomponent/index.md), `children` is called only with a successful result.

## [When it re-runs](https://www.gooddata.ai/docs/gooddata-ui/latest/data-layer/raw-execute/#when-it-re-runs)

- [`RawExecute`](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui/sdk-ui.rawexecute/index.md) starts a new execution when `execution.fingerprint()` changes. A prepared execution rebuilt with the same definition on every render does not start a new one.
- It also starts a new execution when `window` changes by deep comparison, or when `onError`, `onLoadingChanged`, `onLoadingFinish`, or `onLoadingStart` changes by reference. Memoize these callbacks.
- Calling `reload()` starts a new execution at any time.
- When a new execution starts before the running one finishes, the running one is canceled. The request itself keeps running unless `enableExecutionCancelling` is `true`; then its signal is aborted.

## [Notes](https://www.gooddata.ai/docs/gooddata-ui/latest/data-layer/raw-execute/#notes)

- Set `loadOnMount={false}` to skip the initial run, and call `reload()` to start it, for example after a user action.
- Without `window`, [`RawExecute`](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui/sdk-ui.rawexecute/index.md) reads all data. Pass `window` with `offset` and `size` arrays to read one page of a large result.
- `exportTitle` defaults to `"RawExecute"`.

## [Props](https://www.gooddata.ai/docs/gooddata-ui/latest/data-layer/raw-execute/#props)

| Prop | Type | Required | Description | Inherited from |
|------|------|----------|-------------|----------------|
| [`children`](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui/sdk-ui.irawexecuteprops/index.md#irawexecutepropschildren) | `(executionResult:` [`WithLoadingResult`](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui/sdk-ui.withloadingresult/index.md)`) => ReactElement \| null` | Yes | Child component to which rendering is delegated. | — |
| [`execution`](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui/sdk-ui.irawexecuteprops/index.md#irawexecutepropsexecution) | [`IPreparedExecution`](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.ipreparedexecution/index.md) | Yes | Prepared execution which the executor will drive to completion and will obtain data from. | — |
| [`enableExecutionCancelling`](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui/sdk-ui.irawexecuteprops/index.md#irawexecutepropsenableexecutioncancelling) | `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 | — |
| [`ErrorComponent`](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui/sdk-ui.irawexecuteprops/index.md#irawexecutepropserrorcomponent) | [`IExecuteErrorComponent`](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui/sdk-ui.iexecuteerrorcomponent/index.md) | No | Provide component for rendering of the error state. | — |
| [`exportTitle`](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui/sdk-ui.irawexecuteprops/index.md#irawexecutepropsexporttitle) | `string` | No | Name to use for files exported from this component. | — |
| [`LoadingComponent`](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui/sdk-ui.irawexecuteprops/index.md#irawexecutepropsloadingcomponent) | [`IExecuteLoadingComponent`](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui/sdk-ui.iexecuteloadingcomponent/index.md) | No | Provide component for rendering of the loading state. | — |
| [`loadOnMount`](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui/sdk-ui.irawexecuteprops/index.md#irawexecutepropsloadonmount) | `boolean` | No | Indicates whether the executor should trigger execution and loading right after it is mounted. | — |
| [`window`](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui/sdk-ui.irawexecuteprops/index.md#irawexecutepropswindow) | [`DataViewWindow`](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui/sdk-ui.dataviewwindow/index.md) | No | Specifies whether RawExecute should load all data from backend or just a particular window - specified by offset and size of the window. | — |
| [`onError`](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui/sdk-ui.iwithloadingevents/index.md#iwithloadingeventsonerror) | `(error:` [`GoodDataSdkError`](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui/sdk-ui.gooddatasdkerror/index.md)`, props: TProps) => void` | No | If specified, this function will be called in case loading runs into an error. | [`IWithLoadingEvents`](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui/sdk-ui.iwithloadingevents/index.md) |
| [`onExportReady`](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui/sdk-ui.iwithloadingevents/index.md#iwithloadingeventsonexportready) | `(exportFunction:` [`IExportFunction`](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui/sdk-ui.iexportfunction/index.md)`, props: TProps) => void` | No | Called when loading finishes and it is possible to export the underlying data. Function that does the export will be provided on the callback. | [`IWithLoadingEvents`](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui/sdk-ui.iwithloadingevents/index.md) |
| [`onLoadingChanged`](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui/sdk-ui.iwithloadingevents/index.md#iwithloadingeventsonloadingchanged) | `(isLoading: boolean, props: TProps) => void` | No | Called when loading starts and finishes, indicating the current state using the `isLoading` parameter. | [`IWithLoadingEvents`](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui/sdk-ui.iwithloadingevents/index.md) |
| [`onLoadingFinish`](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui/sdk-ui.iwithloadingevents/index.md#iwithloadingeventsonloadingfinish) | `(result:` [`DataViewFacade`](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui/sdk-ui.dataviewfacade/index.md)`, props: TProps) => void` | No | Called when loading finishes. | [`IWithLoadingEvents`](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui/sdk-ui.iwithloadingevents/index.md) |
| [`onLoadingStart`](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui/sdk-ui.iwithloadingevents/index.md#iwithloadingeventsonloadingstart) | `(props: TProps) => void` | No | Called when loading starts. | [`IWithLoadingEvents`](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui/sdk-ui.iwithloadingevents/index.md) |
