Skip to content

Commit

Permalink
fix use-resource tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Varixo committed Aug 12, 2024
1 parent 1b4f133 commit 39a256a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions packages/qwik/src/core/use/use-resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,9 @@ function getResourceValueAsPromise<T>(props: ResourceProps<T>): Promise<JSXOutpu
const resource = props.value as ResourceReturnInternal<T> | Promise<T> | Signal<T>;
if (isResourceReturn(resource)) {
const isBrowser = !isServerPlatform();
// create a subscription for the resource._state changes
const state = resource._state;
if (isBrowser) {
const state = resource._state;
DEBUG && debugLog(`RESOURCE_CMP.${state}`, 'VALUE: ' + untrack(() => resource._resolved));

if (state === 'pending' && props.onPending) {
Expand All @@ -272,7 +273,7 @@ function getResourceValueAsPromise<T>(props: ResourceProps<T>): Promise<JSXOutpu
return Promise.resolve(resource._error!).then(props.onRejected);
} else {
// resolved, pending without onPending prop or rejected with onRejected prop
return Promise.resolve(resource._resolved as T).then(props.onResolved);
return Promise.resolve(untrack(() => resource._resolved) as T).then(props.onResolved);
}
}
return resource.value.then(
Expand Down
2 changes: 1 addition & 1 deletion packages/qwik/src/core/use/use-task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ export const runResource = <T>(
if (prop) {
return (obj as Record<string, unknown>)[prop];
} else if (isSignal2(obj)) {
return obj.untrackedValue;
return obj.value;
} else {
return obj;
}
Expand Down

0 comments on commit 39a256a

Please sign in to comment.