# Function ExecuteQuery

ExecuteQuery(props, deprecatedLegacyContext?): null | ReactElement< any, any >

Executes a query and renders a function as child component. The child component is passed the state of the query as defined in QueryState.

This component takes the Children Prop Pattern and offers an alternative approach to the useExecuteQuery hook.

# Parameters

Parameter Type Description
props ExecuteQueryProps ExecuteQuery properties
deprecatedLegacyContext? any ::: warning Deprecated

:::

See

React Docs (opens new window)

# Returns

null | ReactElement< any, any >

ExecuteQuery component

# Example

Example of using the component to query the Sample ECommerce data source:

<ExecuteQuery
  dataSource={DM.DataSource}
  dimensions={[DM.Commerce.AgeRange]}
  measures={[measureFactory.sum(DM.Commerce.Revenue)]}
  filters={[filterFactory.greaterThan(DM.Commerce.Revenue, 1000)]}
>
{
  ({data, isLoading, isError}) => {
    if (isLoading) {
      return <div>Loading...</div>;
    }
    if (isError) {
      return <div>Error</div>;
    }
    if (data) {
      console.log(data);
      return <div>{`Total Rows: ${data.rows.length}`}</div>;
    }
    return null;
  }
}
</ExecuteQuery>