-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7263 from damianpumar/fix/remove-proxy-function-7254
fix(core): store property descriptor handling
- Loading branch information
Showing
3 changed files
with
69 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
starters/apps/qwikcity-test/src/routes/issue7254/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { component$, Resource, useResource$, useStore } from "@builder.io/qwik"; | ||
|
||
import { server$ } from "@builder.io/qwik-city"; | ||
|
||
export interface Hello { | ||
print: string; | ||
} | ||
|
||
const hello = server$((hello: Hello) => { | ||
// Error: 'getOwnPropertyDescriptor' on proxy: trap returned descriptor for property 'print' that is incompatible with the existing property in the proxy target | ||
return helloBar(hello); | ||
}); | ||
|
||
const helloBar = server$( | ||
(hello: Hello): Promise<string> => | ||
new Promise((res) => { | ||
setTimeout(() => { | ||
res(hello.print + " Bar"); | ||
}, 200); | ||
}), | ||
); | ||
export default component$(() => { | ||
const helloStore = useStore<Hello>({ print: "hello" }); | ||
const resource = useResource$(({ track }) => { | ||
track(() => helloStore.print); | ||
|
||
return hello(helloStore); | ||
}); | ||
|
||
return ( | ||
<> | ||
<Resource | ||
value={resource} | ||
onPending={() => <div>Loading...</div>} | ||
onRejected={(error) => <div>Error: {error.message}</div>} | ||
onResolved={(data) => <div>Data: {data}</div>} | ||
/> | ||
|
||
<button | ||
onClick$={() => { | ||
helloStore.print = "Foo"; | ||
}} | ||
> | ||
Reset | ||
</button> | ||
</> | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { expect, test } from "@playwright/test"; | ||
|
||
test.describe("Resource", () => { | ||
test("should handle the resource correctly", async ({ page }) => { | ||
await page.goto("/qwikcity-test/issue7254/"); | ||
|
||
await page.getByText("Data: hello Bar"); | ||
|
||
await page.getByRole("button", { name: "Reset" }).click(); | ||
|
||
await expect(page.getByText("Data: Foo Bar")).toBeVisible(); | ||
}); | ||
}); |