-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
Since this commit:
https://github.com/refinedev/refine/blame/3bb1d1ea3ba72f6ca24a703ccef88de29a1782f3/packages/core/src/hooks/data/useCustom.ts#L234
useCustom always returns an object for result.data. This is seems to be an undocumented breaking change as any code relying on data being null/undefined while loading will break.
Additionally, the typings are seemingly incorrect.
export type UseCustomReturnType<TData, TError> = {
query: QueryObserverResult<CustomResponse<TData>, TError>;
result: {
data: CustomResponse<TData>["data"];
};
} & UseLoadingOvertimeReturnType;While data is always defined now, the type is incorrect because data is an empty object while loading and not CustomResponse<TData>["data"]
This means any errors because of this is completely invisible until you actually run the code
Steps To Reproduce
type MyCustomData = {
id: string;
someProperty: number[];
};
const { result } = useCustom<MyCustomData>({ url: 'something', method: 'get' });
result.data.someProperty.map(() => console.log);Expected behavior
I expect a type error because result.data.someProperty could be undefined.
Additional Context
No response
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working