Skip to content

Commit c5b8cbd

Browse files
committed
πŸ› fix jsxImportSource issues.
1 parent fc59c9d commit c5b8cbd

7 files changed

Lines changed: 31 additions & 27 deletions

File tree

β€Ž@coven/pair/README.mdβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<!-- deno-coverage-ignore-file -->
12
<img alt="Coven Engineering Pair logo" src="https://raw.githubusercontent.com/covenengineering/libraries/main/@coven/pair/logo.svg" height="108" />
23

34
[![JSR](https://jsr.io/badges/@coven/pair)](https://coven.to/pair)

β€Ž@coven/pair/deno.jsonβ€Ž

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
{
22
"$schema": "https://raw.githubusercontent.com/denoland/deno/main/cli/schemas/config-file.v1.json",
3-
"compilerOptions": {
4-
"jsx": "react-jsx",
5-
"jsxImportSource": "preact"
6-
},
73
"exports": {
84
"./preact": "./preact/mod.ts",
95
"./react": "./react/mod.ts"
106
},
117
"imports": {
128
"@types/react": "npm:@types/react@^19.2.7",
139
"@types/react-dom": "npm:@types/react-dom@^19.2.3",
14-
"preact": "npm:preact@^10.28.0",
10+
"preact": "npm:preact@^10.28.1",
1511
"preact-render-to-string": "npm:preact-render-to-string@^6.6.4",
1612
"react": "npm:react@^19.2.3",
1713
"react-dom": "npm:react-dom@^19.2.3"

β€Ž@coven/pair/preact/PairedRenderFunction.tsβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import type { Attributes, VNode } from "preact";
66
*
77
* @example
88
* ```tsx
9+
* /** @jsxImportSource preact *\/
910
* import { createElement, Fragment } from "preact";
1011
*
1112
* const Example: PairedRenderFunction<() => number> = hook =>

β€Ž@coven/pair/preact/pair.tsβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import type { PairedComponentProperties } from "./PairedComponentProperties.ts";
66
*
77
* @example
88
* ```tsx
9+
* /** @jsxImportSource preact *\/
910
* import { useState } from "preact/hooks";
1011
*
1112
* const useCount = (initialCount: number) => {
Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
import { pair, type PairedComponentProperties } from "@coven/pair/preact";
22
import { assertStrictEquals } from "@std/assert";
33
import { renderToString } from "preact-render-to-string";
4-
import { useState } from "preact/hooks";
4+
import { useCallback, useState } from "preact/hooks";
5+
import { jsx } from "preact/jsx-runtime";
56

67
const Render = (usePairedState: typeof useState) => {
78
const [count, setCount] = usePairedState(0);
8-
9-
return (
10-
<button onClick={() => setCount(count + 1)} type="button">
11-
{count}
12-
</button>
9+
const onClick = useCallback(
10+
() => setCount((currentCount) => currentCount + 1),
11+
[],
1312
);
13+
14+
return jsx("button", { children: count, onClick, type: "button" });
1415
};
1516

1617
const Wanted = ({ children }: PairedComponentProperties<typeof useState>) =>
@@ -24,17 +25,17 @@ Deno.test(
2425
"Generated HTML with a prop should be the same from using `pair` or doing everything manually",
2526
() =>
2627
assertStrictEquals(
27-
renderToString(<PairedState key={key}>{Render}</PairedState>),
28-
renderToString(<Wanted key={key}>{Render}</Wanted>),
28+
renderToString(jsx(PairedState, { key, children: Render })),
29+
renderToString(jsx(Wanted, { key, children: Render })),
2930
),
3031
);
3132

3233
Deno.test(
3334
"Generated HTML should be the same from using `pair` or doing everything manually",
3435
() =>
3536
assertStrictEquals(
36-
renderToString(<PairedState>{Render}</PairedState>),
37-
renderToString(<Wanted>{Render}</Wanted>),
37+
renderToString(jsx(PairedState, { children: Render })),
38+
renderToString(jsx(Wanted, { children: Render })),
3839
),
3940
);
4041

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
1-
/** @jsxImportSource react */
21
import { pair, type PairedComponentProperties } from "@coven/pair/react";
32
import { assertStrictEquals } from "@std/assert";
4-
import { useState } from "react";
3+
import { useCallback, useState } from "react";
54
import { renderToString } from "react-dom/server";
5+
import { jsx } from "react/jsx-runtime";
66

77
const Render = (usePairedState: typeof useState) => {
88
const [count, setCount] = usePairedState(0);
9-
10-
return (
11-
<button onClick={() => setCount(count + 1)} type="button">
12-
{count}
13-
</button>
9+
const onClick = useCallback(
10+
() => setCount((currentCount) => currentCount + 1),
11+
[],
1412
);
13+
14+
return jsx("button", {
15+
children: count,
16+
onClick,
17+
type: "button",
18+
});
1519
};
1620

1721
const Wanted = ({ children }: PairedComponentProperties<typeof useState>) =>
@@ -25,17 +29,17 @@ Deno.test(
2529
"Generated HTML with a prop should be the same from using `pair` or doing everything manually",
2630
() =>
2731
assertStrictEquals(
28-
renderToString(<PairedState key={key}>{Render}</PairedState>),
29-
renderToString(<Wanted key={key}>{Render}</Wanted>),
32+
renderToString(jsx(PairedState, { key, children: Render })),
33+
renderToString(jsx(Wanted, { key, children: Render })),
3034
),
3135
);
3236

3337
Deno.test(
3438
"Generated HTML should be the same from using `pair` or doing everything manually",
3539
() =>
3640
assertStrictEquals(
37-
renderToString(<PairedState>{Render}</PairedState>),
38-
renderToString(<Wanted>{Render}</Wanted>),
41+
renderToString(jsx(PairedState, { children: Render })),
42+
renderToString(jsx(Wanted, { children: Render })),
3943
),
4044
);
4145

β€Ž@simulcast/preact/deno.jsonβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"imports": {
99
"@testing-library/preact": "npm:@testing-library/preact@^3.2.4",
1010
"@testing-library/user-event": "npm:@testing-library/user-event@^14.6.1",
11-
"preact": "npm:preact@^10.28.0"
11+
"preact": "npm:preact@^10.28.1"
1212
},
1313
"name": "@simulcast/preact",
1414
"version": "0.8.5"

0 commit comments

Comments
Β (0)