Skip to content
Prev Previous commit
Next Next commit
Avoid all functions from preact/compat
  • Loading branch information
Archmonger committed Jun 14, 2025
commit 9d63a8ae8c16df568d86f3e1f22a2c5abe8f8b01
15 changes: 7 additions & 8 deletions src/js/src/components.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
import { DjangoFormProps, HttpRequestProps } from "./types";
import React from "preact/compat";
import ReactDOM from "preact/compat";
import { useEffect } from "preact/hooks";
import { render, createElement } from "preact";
/**
* Interface used to bind a ReactPy node to React.
*/
export function bind(node) {
return {
create: (type, props, children) =>
React.createElement(type, props, ...children),
create: (type, props, children) => createElement(type, props, ...children),
render: (element) => {
ReactDOM.render(element, node);
render(element, node);
},
unmount: () => ReactDOM.unmountComponentAtNode(node),
unmount: () => render(null, node),
};
}

export function DjangoForm({
onSubmitCallback,
formId,
}: DjangoFormProps): null {
React.useEffect(() => {
useEffect(() => {
const form = document.getElementById(formId) as HTMLFormElement;

// Submission event function
Expand Down Expand Up @@ -64,7 +63,7 @@ export function DjangoForm({
}

export function HttpRequest({ method, url, body, callback }: HttpRequestProps) {
React.useEffect(() => {
useEffect(() => {
fetch(url, {
method: method,
body: body,
Expand Down
Loading