Fix non-default imports for NoSSRComponent (#1548)
This commit is contained in:
parent
2ff823e89a
commit
2eefb5d26c
@ -799,4 +799,10 @@ class NoSSRComponent(Component):
|
|||||||
def _get_custom_code(self) -> str:
|
def _get_custom_code(self) -> str:
|
||||||
opts_fragment = ", { ssr: false });"
|
opts_fragment = ", { ssr: false });"
|
||||||
library_import = f"const {self.tag} = dynamic(() => import('{self.library}')"
|
library_import = f"const {self.tag} = dynamic(() => import('{self.library}')"
|
||||||
return "".join((library_import, opts_fragment))
|
mod_import = (
|
||||||
|
# https://nextjs.org/docs/pages/building-your-application/optimizing/lazy-loading#with-named-exports
|
||||||
|
f".then((mod) => mod.{self.tag})"
|
||||||
|
if not self.is_default
|
||||||
|
else ""
|
||||||
|
)
|
||||||
|
return "".join((library_import, mod_import, opts_fragment))
|
||||||
|
@ -20,6 +20,8 @@ class Plotly(PlotlyLib):
|
|||||||
|
|
||||||
tag = "Plot"
|
tag = "Plot"
|
||||||
|
|
||||||
|
is_default = True
|
||||||
|
|
||||||
# The figure to display. This can be a plotly figure or a plotly data json.
|
# The figure to display. This can be a plotly figure or a plotly data json.
|
||||||
data: Var[Figure]
|
data: Var[Figure]
|
||||||
|
|
||||||
|
@ -15,6 +15,8 @@ class ReactPlayerComponent(NoSSRComponent):
|
|||||||
|
|
||||||
tag = "ReactPlayer"
|
tag = "ReactPlayer"
|
||||||
|
|
||||||
|
is_default = True
|
||||||
|
|
||||||
# The url of a video or song to play
|
# The url of a video or song to play
|
||||||
url: Var[str]
|
url: Var[str]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user