CB-3889 fix: useResource sync (#1957)

Co-authored-by: EvgeniaBzzz <139753579+EvgeniaBzzz@users.noreply.github.com>
This commit is contained in:
Alexey
2023-08-25 18:39:52 +03:00
committed by GitHub
co-authored by EvgeniaBzzz
parent 7769e1c7bf
commit 6affba2d40
@@ -462,12 +462,26 @@ export function useResource<
};
}, []);
useEffect(() => {
refObj.use(key);
if (result.canLoad && !result.isError()) {
result.load();
}
}, [result.canLoad]);
useEffect(
() =>
reaction(
() => ({
canLoad: result.canLoad,
loadKey: propertiesRef.key,
}),
({ canLoad, loadKey }) => {
refObj.use(loadKey);
if (canLoad && !result.isError()) {
result.load();
}
},
{
fireImmediately: true,
delay: 100,
},
),
[],
);
if (actions?.forceSuspense) {
result.data;