Skip to content

Conversation

Archmonger
Copy link
Contributor

@Archmonger Archmonger commented Mar 14, 2025

Description

Removes usage of react from the reactpy-django client and utilize preact instead.

This also required doing some overrides to force @reactpy/client to utilize preact.

Checklist

Please update this checklist as you complete each item:

  • Tests have been developed for bug fixes or new functionality.
  • The changelog has been updated, if necessary.
  • Documentation has been updated, if necessary.
  • GitHub Issues closed by this PR have been linked.

By submitting this pull request I agree that all contributions comply with this project's open source license(s).

@Archmonger Archmonger marked this pull request as ready for review June 14, 2025 13:07
@Archmonger Archmonger requested a review from a team as a code owner June 14, 2025 13:07
@Archmonger Archmonger requested a review from Copilot June 14, 2025 13:09
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-react or 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", 
@Archmonger Archmonger merged commit c0d16c4 into reactive-python:main Jun 14, 2025
37 of 77 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant