Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function useStatefulResource<
Params extends Readonly,
S extends Schema
>(fetchShape: ReadShape, params: Params | null) {
const maybePromise = useRetrieve(fetchShape, params);
const state = useContext(__INTERNAL__.StateContext);
const [denormalized, ready] = useDenormalized(fetchShape, params, state);
const loading = Boolean(
!__INTERNAL__.hasUsableData(ready, fetchShape) &&
maybePromise &&
typeof maybePromise.then === 'function',
);
const error = useError(fetchShape, params, ready);
return {
data: denormalized,
loading,
error,
};
}