Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include emotion inside of dynamic components #4052

Merged
merged 10 commits into from
Oct 3, 2024
Merged
15 changes: 13 additions & 2 deletions reflex/components/dynamic.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ def get_cdn_url(lib: str) -> str:
return f"https://cdn.jsdelivr.net/npm/{lib}" + "/+esm"


bundled_libraries = {"react", "@radix-ui/themes"}
bundled_libraries = {
"react",
"@radix-ui/themes",
"@emotion/react",
}


def bundle_library(component: "Component"):
Expand Down Expand Up @@ -127,7 +131,14 @@ def make_component(component: Component) -> str:

module_code_lines.insert(0, "const React = window.__reflex.react;")

return "//__reflex_evaluate\n" + "\n".join(module_code_lines)
return "\n".join(
[
"//__reflex_evaluate",
"/** @jsx jsx */",
"const { jsx } = window.__reflex['@emotion/react']",
*module_code_lines,
]
)

@transform
def evaluate_component(js_string: Var[str]) -> Var[Component]:
Expand Down
Loading