Change tearDownReactContext ordering to prevent null assertion

Summary:
In `tearDownReactContext`, `reactContext.destroy()` sets `mCatalystInstance` to null. We cannot call `reactContext.getCatalystInstance()` after that without hitting an assertion. Change ordering so that doesn't happen in reload or teardown.

Changelog: [Internal]

Reviewed By: makovkastar

Differential Revision: D18041279

fbshipit-source-id: 22658dc506b76cf58aee1008841abacfe9410c9d
This commit is contained in:
Joshua Gross
2019-10-21 11:45:56 -07:00
committed by Facebook Github Bot
parent 585dfff22b
commit cd12f256e9
@@ -1126,9 +1126,12 @@ public class ReactInstanceManager {
}
}
// Remove memory pressure listener before tearing down react context
// We cannot access the CatalystInstance after destroying the ReactContext.
mMemoryPressureRouter.removeMemoryPressureListener(reactContext.getCatalystInstance());
reactContext.destroy();
mDevSupportManager.onReactInstanceDestroyed(reactContext);
mMemoryPressureRouter.removeMemoryPressureListener(reactContext.getCatalystInstance());
}
/** @return instance of {@link ReactContext} configured a {@link CatalystInstance} set */