Switch from react to preact#285
Merged
Archmonger merged 14 commits intoreactive-python:mainfrom Jun 14, 2025
Merged
Conversation
4 tasks
There was a problem hiding this comment.
Pull Request Overview
This PR replaces React with Preact in the ReactPy-Django client, updates build and dependency configurations, and adjusts related code and tests for Preact compatibility.
- Configure TypeScript and package aliases so “react” and “react-dom” resolve to Preact/compat
- Refactor mounting and component utilities to use Preact’s
render,createElement, and hooks - Update test utilities to simplify console logging and ignore print statements via ruff
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_app/tests/utils.py | Removed custom logging helper, replaced with inline print for Playwright console events |
| src/js/tsconfig.json | New TS config enabling Preact JSX, path aliases for React imports |
| src/js/src/mount.tsx | Swapped out ReactDOM.render for preact.render, added guard for missing mount element |
| src/js/src/components.ts | Replaced React imports with Preact equivalents in bind, DjangoForm, and HttpRequest |
| src/js/src/client.ts | Switched ReactPyClient/ReactPyModule imports to type-only |
| src/js/package.json | Added preact and aliased react/react-dom to Preact, updated dev dependencies |
Comments suppressed due to low confidence (2)
src/js/package.json:9
- [nitpick] Since the codebase now uses Preact instead of React, consider removing
eslint-plugin-reactor switching to a Preact-compatible ESLint plugin to avoid false lint errors.
"eslint-plugin-react": "^7.37.1",
src/js/tsconfig.json:14
- The compiler option
module: "Preserve"is not a valid module target in TypeScript. Consider using a supported value such as"ESNext"or your desired module format.
"module": "Preserve",
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Removes usage of
reactfrom the reactpy-djangoclientand utilizepreactinstead.This also required doing some overrides to force
@reactpy/clientto utilizepreact.Checklist
Please update this checklist as you complete each item:
By submitting this pull request I agree that all contributions comply with this project's open source license(s).