Skip to content

Commit

Permalink
fix: blank screen
Browse files Browse the repository at this point in the history
  • Loading branch information
ynwd committed Dec 1, 2024
1 parent d979084 commit b81c342
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
18 changes: 9 additions & 9 deletions core/render/render.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ Deno.test(
return ctx.next();
});

f.get("/hello", (_, ctx) => {
return ctx.render(<h1>Hello</h1>);
});
// f.get("/hello", (_, ctx) => {
// return ctx.render(<h1>Hello</h1>);
// });

await f.serve();

Expand All @@ -48,12 +48,12 @@ Deno.test(
`<!DOCTYPE html><html><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><title>halaman page</title><link href="/styles.css" rel="stylesheet"/></head><body id="root"><div><p>Count: 0</p><button>Increment</button><button>Decrement</button></div></body><script src="/js/hello`,
);

const helloFetch = await fetch(host + "/hello", { method: "GET" });
const helloFetchHtml = await helloFetch.text();
assertEquals(
helloFetchHtml,
`<h1>Hello</h1>`,
);
// const helloFetch = await fetch(host + "/hello", { method: "GET" });
// const helloFetchHtml = await helloFetch.text();
// assertEquals(
// helloFetchHtml,
// `<h1>Hello</h1>`,
// );

const page = await fetch(host + "/page", { method: "GET" });
const pageHtml = await page.text();
Expand Down
10 changes: 5 additions & 5 deletions core/server/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -499,11 +499,11 @@ if (root) fetchProps(root);
) => {
const ctx = options as Context;
const r = new Render(this);
if (!page) {
ctx.render = <T>(jsx: T) => {
return r.renderJsx(jsx as JSX.Element);
};
}
// if (!page) {
// ctx.render = <T>(jsx: T) => {
// return r.renderJsx(jsx as JSX.Element);
// };
// }
ctx.send = <T>(data: T, status = 200) => {
return createResponse(data, status);
};
Expand Down
4 changes: 3 additions & 1 deletion modules/index/index.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,7 @@ export const handler = async (req: HttpRequest, ctx: Context) => {
destination: "blog/queue",
};

return ctx.render(obj);
const x = await ctx.render(obj);
console.log("x", x.headers);
return x;
};

0 comments on commit b81c342

Please sign in to comment.