diff --git a/Directory.Build.props b/Directory.Build.props
index c225a02d..79c882b9 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -5,7 +5,7 @@
2.0.0.0
2.0.0.0
- 5.120.3
+ 5.120.4
OutSystems
ReactView
Copyright © OutSystems 2023
diff --git a/ReactViewControl/ReactViewRender.cs b/ReactViewControl/ReactViewRender.cs
index 38f5a8e8..bc713cfd 100644
--- a/ReactViewControl/ReactViewRender.cs
+++ b/ReactViewControl/ReactViewRender.cs
@@ -26,6 +26,7 @@ internal partial class ReactViewRender : IChildViewHost, IDisposable {
private Dictionary Frames { get; } = new Dictionary();
private Dictionary> RecoverableFrames { get; } = new Dictionary>();
+ private Dictionary> ChildViewModules { get; } = new Dictionary>();
private ExtendedWebView WebView { get; }
private Assembly UserCallingAssembly { get; }
@@ -205,6 +206,7 @@ private void OnWebViewJavascriptContextReleased(string frameName) {
Frames.Clear();
Frames.Add(mainFrame.Name, mainFrame);
+ ChildViewModules.Clear();
var previousComponentReady = mainFrame.IsComponentReadyToLoad;
mainFrame.Reset();
mainFrame.IsComponentReadyToLoad = previousComponentReady;
@@ -407,6 +409,9 @@ public bool AddChildView(IViewModule childView, string frameName) {
private void BindComponentToFrame(IViewModule component, FrameInfo frame) {
frame.Component = component;
component.Bind(frame, this);
+ if (!frame.IsMain) {
+ ChildViewModules[frame.Name] = new WeakReference(component);
+ }
}
///
@@ -605,6 +610,16 @@ private FrameInfo GetOrCreateFrame(string frameName) {
Frames[frameName] = newFrame;
AddPlugins(PluginsFactory(), newFrame);
+ // Rebind the existing IViewModule (kept by the consumer) to the new frame on remount
+ if (!newFrame.IsMain && ChildViewModules.TryGetValue(frameName, out var weakComponent)) {
+ if (weakComponent.TryGetTarget(out var existingComponent)) {
+ BindComponentToFrame(existingComponent, newFrame);
+ newFrame.IsComponentReadyToLoad = true;
+ } else {
+ ChildViewModules.Remove(frameName);
+ }
+ }
+
return newFrame;
}