-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
Describe the bug
useCubeQuery isLoading is set to false early when using React 18.
To Reproduce
Steps to reproduce the behavior:
With a fork of React sandbox from the Cubejs React docs updated to use React 18 here
- Load the Sandbox
- Open the Sandbox console view
- View the properties output in the console
Expected behavior
The isLoading
should remain true
until the raw
data value is an array (this is what we see when the sandbox example uses React 16).
Actual behavior
The isLoading
becomes true
while raw
data value is still null (with React 18 dependency)
Screenshots

Minimally reproducible Cube Schema
See the linked sandbox instance. The significant code is:
const App = () => {
// Query data from Cube.js Backend
const { resultSet, isLoading, error, progress } = useCubeQuery({
measures: ["Orders.count"],
dimensions: ["ProductCategories.name"],
filters: [
{
member: "ProductCategories.name",
operator: "equals",
values: ["Electronics"],
},
],
timeDimensions: [
{
dimension: "Orders.createdAt",
granularity: "month",
dateRange: ["2022-01-01", "2023-01-01"],
},
],
});
const raw = resultSet?.rawData();
React.useEffect(() => {
console.log({ isLoading, raw, time: performance.now() });
}, [isLoading, raw]);
if (isLoading) {
return (
<div>
{(progress && progress.stage && progress.stage.stage) || "Loading..."}
</div>
);
}
if (error) {
return <div>{error.toString()}</div>;
}
return <pre>{JSON.stringify(raw, null, 2)}</pre>;
};
Version:
@cubejs-client: @latest
React: 18
Chrome: 139.0.7258.155
MS Edge: 139.0.3405.125
Additional context
I can reproduce this issue as a minimal test case in our own project as well as the sandbox. This occurs with both dev and production builds.