@@ -36,6 +36,7 @@ def module_from_url(
3636 fallback : Optional [Any ] = None ,
3737 resolve_exports : bool = IDOM_DEBUG_MODE .current ,
3838 resolve_exports_depth : int = 5 ,
39+ unmount_before_update : bool = False ,
3940) -> WebModule :
4041 """Load a :class:`WebModule` from a :data:`URL_SOURCE`
4142
@@ -49,6 +50,11 @@ def module_from_url(
4950 Whether to try and find all the named exports of this module.
5051 resolve_exports_depth:
5152 How deeply to search for those exports.
53+ unmount_before_update:
54+ Cause the component to be unmounted before each update. This option should
55+ only be used if the imported package failes to re-render when props change.
56+ Using this option has negative performance consequences since all DOM
57+ elements must be changed on each render. See :issue:`461` for more info.
5258 """
5359 return WebModule (
5460 source = url ,
@@ -60,6 +66,7 @@ def module_from_url(
6066 if resolve_exports
6167 else None
6268 ),
69+ unmount_before_update = unmount_before_update ,
6370 )
6471
6572
@@ -70,6 +77,7 @@ def module_from_template(
7077 fallback : Optional [Any ] = None ,
7178 resolve_exports : bool = IDOM_DEBUG_MODE .current ,
7279 resolve_exports_depth : int = 5 ,
80+ unmount_before_update : bool = False ,
7381) -> WebModule :
7482 """Create a :class:`WebModule` from a framework template
7583
@@ -98,6 +106,11 @@ def module_from_template(
98106 Whether to try and find all the named exports of this module.
99107 resolve_exports_depth:
100108 How deeply to search for those exports.
109+ unmount_before_update:
110+ Cause the component to be unmounted before each update. This option should
111+ only be used if the imported package failes to re-render when props change.
112+ Using this option has negative performance consequences since all DOM
113+ elements must be changed on each render. See :issue:`461` for more info.
101114 """
102115 # We do this since the package may be any valid URL path. Thus we may need to strip
103116 # object parameters or query information so we save the resulting template under the
@@ -129,6 +142,7 @@ def module_from_template(
129142 if resolve_exports
130143 else None
131144 ),
145+ unmount_before_update = unmount_before_update ,
132146 )
133147
134148
@@ -139,6 +153,7 @@ def module_from_file(
139153 resolve_exports : bool = IDOM_DEBUG_MODE .current ,
140154 resolve_exports_depth : int = 5 ,
141155 symlink : bool = False ,
156+ unmount_before_update : bool = False ,
142157) -> WebModule :
143158 """Load a :class:`WebModule` from a :data:`URL_SOURCE` using a known framework
144159
@@ -156,6 +171,11 @@ def module_from_file(
156171 Whether to try and find all the named exports of this module.
157172 resolve_exports_depth:
158173 How deeply to search for those exports.
174+ unmount_before_update:
175+ Cause the component to be unmounted before each update. This option should
176+ only be used if the imported package failes to re-render when props change.
177+ Using this option has negative performance consequences since all DOM
178+ elements must be changed on each render. See :issue:`461` for more info.
159179 """
160180 source_file = Path (file )
161181 target_file = _web_module_path (name )
@@ -179,6 +199,7 @@ def module_from_file(
179199 if resolve_exports
180200 else None
181201 ),
202+ unmount_before_update = unmount_before_update ,
182203 )
183204
184205
@@ -189,6 +210,7 @@ class WebModule:
189210 default_fallback : Optional [Any ]
190211 export_names : Optional [Set [str ]]
191212 file : Optional [Path ]
213+ unmount_before_update : bool
192214
193215
194216@overload
@@ -250,7 +272,10 @@ def export(
250272
251273
252274def _make_export (
253- web_module : WebModule , name : str , fallback : Optional [Any ], allow_children : bool
275+ web_module : WebModule ,
276+ name : str ,
277+ fallback : Optional [Any ],
278+ allow_children : bool ,
254279) -> VdomDictConstructor :
255280 return partial (
256281 make_vdom_constructor (
@@ -261,6 +286,7 @@ def _make_export(
261286 source = web_module .source ,
262287 sourceType = web_module .source_type ,
263288 fallback = (fallback or web_module .default_fallback ),
289+ unmountBeforeUpdate = web_module .unmount_before_update ,
264290 ),
265291 )
266292
0 commit comments