Skip to content

Commit a8a8f4a

Browse files
committed
Switch from react to preact
1 parent c8ec533 commit a8a8f4a

File tree

6 files changed

+39
-6
lines changed

6 files changed

+39
-6
lines changed

src/js/bun.lockb

342 Bytes
Binary file not shown.

src/js/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"@pyscript/core": "^0.6",
1616
"@reactpy/client": "^0.3.2",
1717
"event-to-object": "^0.1.2",
18-
"morphdom": "^2.7.4"
18+
"morphdom": "^2.7.4",
19+
"preact": "^10.26.4"
1920
}
2021
}

src/js/src/components.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { DjangoFormProps, HttpRequestProps } from "./types";
2-
import React from "react";
3-
import ReactDOM from "react-dom";
2+
import React from "preact/compat";
3+
import ReactDOM from "preact/compat";
44
/**
55
* Interface used to bind a ReactPy node to React.
66
*/

src/js/src/mount.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { ReactPyDjangoClient } from "./client";
2-
import React from "react";
3-
import ReactDOM from "react-dom";
2+
import ReactDOM from "preact/compat";
43
import { Layout } from "@reactpy/client/src/components";
54

65
export function mountComponent(

src/js/tsconfig.json

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"compilerOptions": {
3+
"esModuleInterop": true,
4+
"jsx": "react-jsx",
5+
"jsxImportSource": "preact",
6+
"target": "esnext",
7+
"module": "esnext",
8+
"moduleResolution": "node",
9+
"composite": true,
10+
"allowJs": false,
11+
"allowSyntheticDefaultImports": true,
12+
"declaration": true,
13+
"declarationMap": true,
14+
"forceConsistentCasingInFileNames": true,
15+
"isolatedModules": true,
16+
"lib": ["DOM", "DOM.Iterable", "esnext"],
17+
"noEmitOnError": true,
18+
"noUnusedLocals": true,
19+
"resolveJsonModule": true,
20+
"skipLibCheck": false,
21+
"sourceMap": true,
22+
"strict": true
23+
}
24+
}

tests/test_app/tests/utils.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,16 @@ def start_playwright_client(cls):
117117
cls.browser = cls.playwright.chromium.launch(headless=bool(headless))
118118
cls.page = cls.browser.new_page()
119119
cls.page.set_default_timeout(10000)
120-
cls.page.on("console", lambda msg: _logger.error("error: %s", msg.text) if msg.type == "error" else None)
120+
cls.page.on("console", cls.playwright_logging)
121+
122+
@staticmethod
123+
def playwright_logging(msg):
124+
if msg.type == "error":
125+
_logger.error(msg.text)
126+
elif msg.type == "warning":
127+
_logger.warning(msg.text)
128+
elif msg.type == "info":
129+
_logger.info(msg.text)
121130

122131
@classmethod
123132
def shutdown_playwright_client(cls):

0 commit comments

Comments
 (0)