Skip to content

Commit 9d63a8a

Browse files
committed
Avoid all functions from preact/compat
1 parent c59c688 commit 9d63a8a

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/js/src/components.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
11
import { DjangoFormProps, HttpRequestProps } from "./types";
2-
import React from "preact/compat";
3-
import ReactDOM from "preact/compat";
2+
import { useEffect } from "preact/hooks";
3+
import { render, createElement } from "preact";
44
/**
55
* Interface used to bind a ReactPy node to React.
66
*/
77
export function bind(node) {
88
return {
9-
create: (type, props, children) =>
10-
React.createElement(type, props, ...children),
9+
create: (type, props, children) => createElement(type, props, ...children),
1110
render: (element) => {
12-
ReactDOM.render(element, node);
11+
render(element, node);
1312
},
14-
unmount: () => ReactDOM.unmountComponentAtNode(node),
13+
unmount: () => render(null, node),
1514
};
1615
}
1716

1817
export function DjangoForm({
1918
onSubmitCallback,
2019
formId,
2120
}: DjangoFormProps): null {
22-
React.useEffect(() => {
21+
useEffect(() => {
2322
const form = document.getElementById(formId) as HTMLFormElement;
2423

2524
// Submission event function
@@ -64,7 +63,7 @@ export function DjangoForm({
6463
}
6564

6665
export function HttpRequest({ method, url, body, callback }: HttpRequestProps) {
67-
React.useEffect(() => {
66+
useEffect(() => {
6867
fetch(url, {
6968
method: method,
7069
body: body,

0 commit comments

Comments
 (0)