Fix ReactInstanceManager unmountApplication

Reviewed By: mdvacca

Differential Revision: D7945746

fbshipit-source-id: 0c2eed9a623e442fa4a4ff29ffa01f025466c9b6
This commit is contained in:
Andrew Chen (Eng) 2018-05-30 15:00:23 -07:00 committed by Facebook Github Bot
parent c6b4f9f2ce
commit 4a9b2a7302
2 changed files with 12 additions and 0 deletions

View File

@ -423,6 +423,7 @@ public class ReactRootView extends SizeMonitoringFrameLayout
public void unmountReactApplication() {
if (mReactInstanceManager != null && mIsAttachedToInstance) {
mReactInstanceManager.detachRootView(this);
mReactInstanceManager = null;
mIsAttachedToInstance = false;
}
mShouldLogContentAppeared = false;

View File

@ -195,4 +195,15 @@ public class RootViewTest {
MotionEvent.obtain(50, new Date().getTime(), MotionEvent.ACTION_HOVER_MOVE, 0, 0, 0));
verifyNoMoreInteractions(eventDispatcher);
}
@Test
public void testRemountApplication() {
ReactInstanceManager instanceManager = mock(ReactInstanceManager.class);
ReactRootView rootView = new ReactRootView(mReactContext);
rootView.startReactApplication(instanceManager, "");
rootView.unmountReactApplication();
rootView.startReactApplication(instanceManager, "");
}
}