Skip to content

Commit b7f5dff

Browse files
committed
attempt 4
1 parent fd9b557 commit b7f5dff

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/js/packages/@reactpy/client/src/bind.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,25 @@ function reactjs_bind(node: HTMLElement, React: any, ReactDOM: any) {
3737
React.createElement(type, props, ...(children || [])),
3838
render: (element: any) => {
3939
if (!root) {
40+
// @ts-ignore
41+
if (node._reactPyRoot) {
42+
// @ts-ignore
43+
node._reactPyRoot.unmount();
44+
}
4045
root = ReactDOM.createRoot(node);
46+
// @ts-ignore
47+
node._reactPyRoot = root;
4148
}
4249
root.render(element);
4350
},
4451
unmount: () => {
4552
if (root) {
4653
root.unmount();
54+
// @ts-ignore
55+
if (node._reactPyRoot === root) {
56+
// @ts-ignore
57+
node._reactPyRoot = null;
58+
}
4759
root = null;
4860
}
4961
},

src/reactpy/reactjs/module.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,11 +204,11 @@ def import_reactjs(
204204
"""
205205
from reactpy import html
206206

207-
if use_local and (framework or version):
207+
if use_local and (framework or version): # nocov
208208
raise ValueError("use_local cannot be used with framework or version")
209209

210210
framework = framework or "preact"
211-
if framework and framework not in {"preact", "react"}:
211+
if framework and framework not in {"preact", "react"}: # nocov
212212
raise ValueError("framework must be 'preact' or 'react'")
213213

214214
# Import map for ReactPy's local framework (re-exported/bundled/minified version of Preact)

0 commit comments

Comments
 (0)