Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch from react to preact #285

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified src/js/bun.lockb
Binary file not shown.
3 changes: 2 additions & 1 deletion src/js/package.json
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@
"@pyscript/core": "^0.6",
"@reactpy/client": "^0.3.2",
"event-to-object": "^0.1.2",
"morphdom": "^2.7.4"
"morphdom": "^2.7.4",
"preact": "^10.26.4"
}
}
4 changes: 2 additions & 2 deletions src/js/src/components.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { DjangoFormProps, HttpRequestProps } from "./types";
import React from "react";
import ReactDOM from "react-dom";
import React from "preact/compat";
import ReactDOM from "preact/compat";
/**
* Interface used to bind a ReactPy node to React.
*/
3 changes: 1 addition & 2 deletions src/js/src/mount.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { ReactPyDjangoClient } from "./client";
import React from "react";
import ReactDOM from "react-dom";
import ReactDOM from "preact/compat";
import { Layout } from "@reactpy/client/src/components";

export function mountComponent(
24 changes: 24 additions & 0 deletions src/js/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"compilerOptions": {
"esModuleInterop": true,
"jsx": "react-jsx",
"jsxImportSource": "preact",
"target": "esnext",
"module": "esnext",
"moduleResolution": "node",
"composite": true,
"allowJs": false,
"allowSyntheticDefaultImports": true,
"declaration": true,
"declarationMap": true,
"forceConsistentCasingInFileNames": true,
"isolatedModules": true,
"lib": ["DOM", "DOM.Iterable", "esnext"],
"noEmitOnError": true,
"noUnusedLocals": true,
"resolveJsonModule": true,
"skipLibCheck": false,
"sourceMap": true,
"strict": true
}
}
11 changes: 10 additions & 1 deletion tests/test_app/tests/utils.py
Original file line number Diff line number Diff line change
@@ -117,7 +117,16 @@ def start_playwright_client(cls):
cls.browser = cls.playwright.chromium.launch(headless=bool(headless))
cls.page = cls.browser.new_page()
cls.page.set_default_timeout(10000)
cls.page.on("console", lambda msg: _logger.error("error: %s", msg.text) if msg.type == "error" else None)
cls.page.on("console", cls.playwright_logging)

@staticmethod
def playwright_logging(msg):
if msg.type == "error":
_logger.error(msg.text)
elif msg.type == "warning":
_logger.warning(msg.text)
elif msg.type == "info":
_logger.info(msg.text)

@classmethod
def shutdown_playwright_client(cls):