Skip to content

Commit 28d6d7b

Browse files
committed
use async helmet
1 parent f0b2075 commit 28d6d7b

File tree

6 files changed

+21
-8
lines changed

6 files changed

+21
-8
lines changed

pyi_hashes.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
"reflex/components/base/meta.pyi": "d9ab3f671c0689bf477ddc823fc567f6",
1212
"reflex/components/base/script.pyi": "b103b2188e1d9761d27c387e7daecf9d",
1313
"reflex/components/base/strict_mode.pyi": "6b72e16caadf7158ab744a0ab751b010",
14-
"reflex/components/core/__init__.pyi": "007170b97e58bdf28b2aee381d91c0c7",
14+
"reflex/components/core/__init__.pyi": "a469d9e61421eeb9a377d26ba7a20436",
1515
"reflex/components/core/auto_scroll.pyi": "10c4cf71d0d0c1d46a8e1205bd119c11",
1616
"reflex/components/core/banner.pyi": "3c07547afc4f215aefd5e5afa409aa25",
1717
"reflex/components/core/clipboard.pyi": "a844eb927d9bc2a43f5e88161b258539",
1818
"reflex/components/core/debounce.pyi": "055da7aa890f44fb4d48bd5978f1a874",
19-
"reflex/components/core/helmet.pyi": "43f8497c8fafe51e29dca1dd535d143a",
19+
"reflex/components/core/helmet.pyi": "3ae693d1cc100ed26b987a563b699514",
2020
"reflex/components/core/html.pyi": "ea5919db8c8172913185977df900f36b",
2121
"reflex/components/core/sticky.pyi": "a9b4492e423f1dd4ccbf270c8ea90157",
2222
"reflex/components/core/upload.pyi": "c11465a3a88e3a374251dd1a16582938",

reflex/app.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
connection_toaster,
6969
)
7070
from reflex.components.core.breakpoints import set_breakpoints
71+
from reflex.components.core.helmet import HelmetProvider
7172
from reflex.components.core.sticky import sticky
7273
from reflex.components.core.upload import Upload, get_upload_dir
7374
from reflex.components.radix import themes
@@ -1158,7 +1159,8 @@ def get_compilation_time() -> str:
11581159
# Add the app wrappers.
11591160
app_wrappers: dict[tuple[int, str], Component] = {
11601161
# Default app wrap component renders {children}
1161-
(0, "AppWrap"): AppWrap.create()
1162+
(0, "AppWrap"): AppWrap.create(),
1163+
(199, "HelmetProvider"): HelmetProvider.create(),
11621164
}
11631165

11641166
if self.theme is not None:

reflex/components/core/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"Foreach",
2929
],
3030
"html": ["html", "Html"],
31-
"helmet": ["Helmet"],
31+
"helmet": ["Helmet", "helmet", "HelmetProvider", "helmet_provider"],
3232
"match": [
3333
"match",
3434
"Match",

reflex/components/core/helmet.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,18 @@
66
class Helmet(Component):
77
"""A helmet component."""
88

9-
library = "react-helmet@6.1.0"
9+
library = "react-helmet[email protected]"
1010

1111
tag = "Helmet"
1212

1313

14+
class HelmetProvider(Component):
15+
"""A helmet provider component."""
16+
17+
library = "[email protected]"
18+
19+
tag = "HelmetProvider"
20+
21+
1422
helmet = Helmet.create
23+
helmet_provider = HelmetProvider.create

reflex/constants/installer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def DEPENDENCIES(cls) -> dict[str, str]:
129129
"@react-router/node": cls._react_router_version,
130130
"sirv-cli": "3.0.1",
131131
"react": cls._react_version,
132-
"react-helmet": "6.1.0",
132+
"react-helmet-async": "2.0.5",
133133
"react-dom": cls._react_version,
134134
"isbot": "5.1.30",
135135
"socket.io-client": "4.8.1",

tests/units/test_app.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,6 +1372,7 @@ def test_app_wrap_compile_theme(
13721372
"const [addEvents, connectErrors] = useContext(EventLoopContext);\n\n\n\n"
13731373
"return ("
13741374
+ ("jsx(StrictMode,{}," if react_strict_mode else "")
1375+
+ "jsx(HelmetProvider,{},"
13751376
+ "jsx(ErrorBoundary,{"
13761377
"""fallbackRender:((event_args) => (jsx("div", ({css:({ ["height"] : "100%", ["width"] : "100%", ["position"] : "absolute", ["backgroundColor"] : "#fff", ["color"] : "#000", ["display"] : "flex", ["alignItems"] : "center", ["justifyContent"] : "center" })}), (jsx("div", ({css:({ ["display"] : "flex", ["flexDirection"] : "column", ["gap"] : "1rem" })}), (jsx("div", ({css:({ ["display"] : "flex", ["flexDirection"] : "column", ["gap"] : "1rem", ["maxWidth"] : "50ch", ["border"] : "1px solid #888888", ["borderRadius"] : "0.25rem", ["padding"] : "1rem" })}), (jsx("h2", ({css:({ ["fontSize"] : "1.25rem", ["fontWeight"] : "bold" })}), "An error occurred while rendering this page.")), (jsx("p", ({css:({ ["opacity"] : "0.75" })}), "This is an error with the application itself.")), (jsx("details", ({}), (jsx("summary", ({css:({ ["padding"] : "0.5rem" })}), "Error message")), (jsx("div", ({css:({ ["width"] : "100%", ["maxHeight"] : "50vh", ["overflow"] : "auto", ["background"] : "#000", ["color"] : "#fff", ["borderRadius"] : "0.25rem" })}), (jsx("div", ({css:({ ["padding"] : "0.5rem", ["width"] : "fit-content" })}), (jsx("pre", ({}), event_args.error.name + \': \' + event_args.error.message + \'\\n\' + event_args.error.stack)))))), (jsx("button", ({css:({ ["padding"] : "0.35rem 0.75rem", ["margin"] : "0.5rem", ["background"] : "#fff", ["color"] : "#000", ["border"] : "1px solid #000", ["borderRadius"] : "0.25rem", ["fontWeight"] : "bold" }),onClick:((_e) => (addEvents([(ReflexEvent("_call_function", ({ ["function"] : (() => (navigator["clipboard"]["writeText"](event_args.error.name + \': \' + event_args.error.message + \'\\n\' + event_args.error.stack))), ["callback"] : null }), ({ })))], [_e], ({ }))))}), "Copy")))))), (jsx("hr", ({css:({ ["borderColor"] : "currentColor", ["opacity"] : "0.25" })}))), (jsx(ReactRouterLink, ({to:"https://reflex.dev"}), (jsx("div", ({css:({ ["display"] : "flex", ["alignItems"] : "baseline", ["justifyContent"] : "center", ["fontFamily"] : "monospace", ["--default-font-family"] : "monospace", ["gap"] : "0.5rem" })}), "Built with ", (jsx("svg", ({"aria-label":"Reflex",css:({ ["fill"] : "currentColor" }),height:"12",role:"img",width:"56",xmlns:"http://www.w3.org/2000/svg"}), (jsx("path", ({d:"M0 11.5999V0.399902H8.96V4.8799H6.72V2.6399H2.24V4.8799H6.72V7.1199H2.24V11.5999H0ZM6.72 11.5999V7.1199H8.96V11.5999H6.72Z"}))), (jsx("path", ({d:"M11.2 11.5999V0.399902H17.92V2.6399H13.44V4.8799H17.92V7.1199H13.44V9.3599H17.92V11.5999H11.2Z"}))), (jsx("path", ({d:"M20.16 11.5999V0.399902H26.88V2.6399H22.4V4.8799H26.88V7.1199H22.4V11.5999H20.16Z"}))), (jsx("path", ({d:"M29.12 11.5999V0.399902H31.36V9.3599H35.84V11.5999H29.12Z"}))), (jsx("path", ({d:"M38.08 11.5999V0.399902H44.8V2.6399H40.32V4.8799H44.8V7.1199H40.32V9.3599H44.8V11.5999H38.08Z"}))), (jsx("path", ({d:"M47.04 4.8799V0.399902H49.28V4.8799H47.04ZM53.76 4.8799V0.399902H56V4.8799H53.76ZM49.28 7.1199V4.8799H53.76V7.1199H49.28ZM47.04 11.5999V7.1199H49.28V11.5999H47.04ZM53.76 11.5999V7.1199H56V11.5999H53.76Z"}))), (jsx("title", ({}), "Reflex"))))))))))))),"""
13771378
"""onError:((_error, _info) => (addEvents([(ReflexEvent("reflex___state____state.reflex___state____frontend_event_exception_state.handle_frontend_exception", ({ ["info"] : ((((_error["name"]+": ")+_error["message"])+"\\n")+_error["stack"]), ["component_stack"] : _info["componentStack"] }), ({ })))], [_error, _info], ({ }))))"""
@@ -1384,7 +1385,7 @@ def test_app_wrap_compile_theme(
13841385
"jsx(MemoizedToastProvider,{},),"
13851386
"jsx(Fragment,{},"
13861387
"children"
1387-
"))))))" + (")" if react_strict_mode else "") + ")"
1388+
")))))))" + (")" if react_strict_mode else "") + ")"
13881389
"\n}"
13891390
)
13901391
assert expected.split(",") == function_app_definition.split(",")
@@ -1445,6 +1446,7 @@ def page():
14451446
"const [addEvents, connectErrors] = useContext(EventLoopContext);\n\n\n\n"
14461447
"return ("
14471448
+ ("jsx(StrictMode,{}," if react_strict_mode else "")
1449+
+ "jsx(HelmetProvider,{},"
14481450
+ "jsx(RadixThemesBox,{},"
14491451
"jsx(ErrorBoundary,{"
14501452
"""fallbackRender:((event_args) => (jsx("div", ({css:({ ["height"] : "100%", ["width"] : "100%", ["position"] : "absolute", ["backgroundColor"] : "#fff", ["color"] : "#000", ["display"] : "flex", ["alignItems"] : "center", ["justifyContent"] : "center" })}), (jsx("div", ({css:({ ["display"] : "flex", ["flexDirection"] : "column", ["gap"] : "1rem" })}), (jsx("div", ({css:({ ["display"] : "flex", ["flexDirection"] : "column", ["gap"] : "1rem", ["maxWidth"] : "50ch", ["border"] : "1px solid #888888", ["borderRadius"] : "0.25rem", ["padding"] : "1rem" })}), (jsx("h2", ({css:({ ["fontSize"] : "1.25rem", ["fontWeight"] : "bold" })}), "An error occurred while rendering this page.")), (jsx("p", ({css:({ ["opacity"] : "0.75" })}), "This is an error with the application itself.")), (jsx("details", ({}), (jsx("summary", ({css:({ ["padding"] : "0.5rem" })}), "Error message")), (jsx("div", ({css:({ ["width"] : "100%", ["maxHeight"] : "50vh", ["overflow"] : "auto", ["background"] : "#000", ["color"] : "#fff", ["borderRadius"] : "0.25rem" })}), (jsx("div", ({css:({ ["padding"] : "0.5rem", ["width"] : "fit-content" })}), (jsx("pre", ({}), event_args.error.name + \': \' + event_args.error.message + \'\\n\' + event_args.error.stack)))))), (jsx("button", ({css:({ ["padding"] : "0.35rem 0.75rem", ["margin"] : "0.5rem", ["background"] : "#fff", ["color"] : "#000", ["border"] : "1px solid #000", ["borderRadius"] : "0.25rem", ["fontWeight"] : "bold" }),onClick:((_e) => (addEvents([(ReflexEvent("_call_function", ({ ["function"] : (() => (navigator["clipboard"]["writeText"](event_args.error.name + \': \' + event_args.error.message + \'\\n\' + event_args.error.stack))), ["callback"] : null }), ({ })))], [_e], ({ }))))}), "Copy")))))), (jsx("hr", ({css:({ ["borderColor"] : "currentColor", ["opacity"] : "0.25" })}))), (jsx(ReactRouterLink, ({to:"https://reflex.dev"}), (jsx("div", ({css:({ ["display"] : "flex", ["alignItems"] : "baseline", ["justifyContent"] : "center", ["fontFamily"] : "monospace", ["--default-font-family"] : "monospace", ["gap"] : "0.5rem" })}), "Built with ", (jsx("svg", ({"aria-label":"Reflex",css:({ ["fill"] : "currentColor" }),height:"12",role:"img",width:"56",xmlns:"http://www.w3.org/2000/svg"}), (jsx("path", ({d:"M0 11.5999V0.399902H8.96V4.8799H6.72V2.6399H2.24V4.8799H6.72V7.1199H2.24V11.5999H0ZM6.72 11.5999V7.1199H8.96V11.5999H6.72Z"}))), (jsx("path", ({d:"M11.2 11.5999V0.399902H17.92V2.6399H13.44V4.8799H17.92V7.1199H13.44V9.3599H17.92V11.5999H11.2Z"}))), (jsx("path", ({d:"M20.16 11.5999V0.399902H26.88V2.6399H22.4V4.8799H26.88V7.1199H22.4V11.5999H20.16Z"}))), (jsx("path", ({d:"M29.12 11.5999V0.399902H31.36V9.3599H35.84V11.5999H29.12Z"}))), (jsx("path", ({d:"M38.08 11.5999V0.399902H44.8V2.6399H40.32V4.8799H44.8V7.1199H40.32V9.3599H44.8V11.5999H38.08Z"}))), (jsx("path", ({d:"M47.04 4.8799V0.399902H49.28V4.8799H47.04ZM53.76 4.8799V0.399902H56V4.8799H53.76ZM49.28 7.1199V4.8799H53.76V7.1199H49.28ZM47.04 11.5999V7.1199H49.28V11.5999H47.04ZM53.76 11.5999V7.1199H56V11.5999H53.76Z"}))), (jsx("title", ({}), "Reflex"))))))))))))),"""
@@ -1459,7 +1461,7 @@ def page():
14591461
"jsx(MemoizedToastProvider,{},),"
14601462
"jsx(Fragment,{},"
14611463
"children"
1462-
")))))))" + (")" if react_strict_mode else "") + "))\n}"
1464+
"))))))))" + (")" if react_strict_mode else "") + "))\n}"
14631465
)
14641466
assert expected.split(",") == function_app_definition.split(",")
14651467

0 commit comments

Comments
 (0)