Skip to content

Commit ac3376e

Browse files
Add Component type
1 parent b037a11 commit ac3376e

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

src/reactpy/executors/asgi/pyscript.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
pyscript_setup_html,
1919
)
2020
from reactpy.executors.utils import html_noscript_to_html, vdom_head_to_html
21-
from reactpy.types import ReactPyConfig, RootComponentConstructor, VdomDict
21+
from reactpy.types import Component, ReactPyConfig, RootComponentConstructor, VdomDict
2222

2323

2424
class ReactPyCsr(ReactPy):
@@ -34,6 +34,7 @@ def __init__(
3434
html_head: VdomDict | None = None,
3535
html_noscript: str
3636
| Path
37+
| Component
3738
| RootComponentConstructor
3839
| None = "Enable JavaScript to view this site.",
3940
html_lang: str = "en",

src/reactpy/executors/asgi/standalone.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
vdom_head_to_html,
3232
)
3333
from reactpy.types import (
34+
Component,
3435
PyScriptOptions,
3536
ReactPyConfig,
3637
RootComponentConstructor,
@@ -52,6 +53,7 @@ def __init__(
5253
html_head: VdomDict | None = None,
5354
html_noscript: str
5455
| Path
56+
| Component
5557
| RootComponentConstructor
5658
| None = "Enable JavaScript to view this site.",
5759
html_lang: str = "en",

src/reactpy/executors/utils.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
REACTPY_RECONNECT_MAX_INTERVAL,
1414
REACTPY_RECONNECT_MAX_RETRIES,
1515
)
16-
from reactpy.types import ReactPyConfig, RootComponentConstructor, VdomDict
16+
from reactpy.types import Component, ReactPyConfig, RootComponentConstructor, VdomDict
1717
from reactpy.utils import import_dotted_path, reactpy_to_string
1818

1919
logger = logging.getLogger(__name__)
@@ -48,12 +48,14 @@ def vdom_head_to_html(head: VdomDict) -> str:
4848

4949

5050
def html_noscript_to_html(
51-
html_noscript: str | Path | RootComponentConstructor | None,
51+
html_noscript: str | Path | Component | RootComponentConstructor | None,
5252
) -> str:
5353
if html_noscript is None:
5454
return ""
5555
if isinstance(html_noscript, Path):
5656
html_noscript = html_noscript.read_text()
57+
elif isinstance(html_noscript, Component):
58+
html_noscript = reactpy_to_string(html_noscript)
5759
elif callable(html_noscript):
5860
html_noscript = reactpy_to_string(html_noscript())
5961
return f"<noscript>{html_noscript}</noscript>"

0 commit comments

Comments
 (0)