From 396e89eb5dd647f1d9c8aea915729c89d089754f Mon Sep 17 00:00:00 2001 From: Khaleel Al-Adhami Date: Mon, 7 Oct 2024 09:36:22 -0700 Subject: [PATCH] bundle next link in window (#4064) --- reflex/components/dynamic.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/reflex/components/dynamic.py b/reflex/components/dynamic.py index 8d0bab669dd..9c498fb6193 100644 --- a/reflex/components/dynamic.py +++ b/reflex/components/dynamic.py @@ -1,6 +1,6 @@ """Components that are dynamically generated on the backend.""" -from typing import TYPE_CHECKING +from typing import TYPE_CHECKING, Union from reflex import constants from reflex.utils import imports @@ -26,14 +26,10 @@ def get_cdn_url(lib: str) -> str: return f"https://cdn.jsdelivr.net/npm/{lib}" + "/+esm" -bundled_libraries = { - "react", - "@radix-ui/themes", - "@emotion/react", -} +bundled_libraries = {"react", "@radix-ui/themes", "@emotion/react", "next/link"} -def bundle_library(component: "Component"): +def bundle_library(component: Union["Component", str]): """Bundle a library with the component. Args: @@ -42,6 +38,9 @@ def bundle_library(component: "Component"): Raises: DynamicComponentMissingLibrary: Raised when a dynamic component is missing a library. """ + if isinstance(component, str): + bundled_libraries.add(component) + return if component.library is None: raise DynamicComponentMissingLibrary("Component must have a library to bundle.") bundled_libraries.add(format_library_name(component.library))