Skip to content

Commit b87abc8

Browse files
authored
Keep propertyBag alive for duration of InstanceDestroyed event (#12364)
* Keep propertyBag alive for duration of InstanceDestroyed event * Change files
1 parent 46d5f9d commit b87abc8

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "Keep propertyBag alive for duration of InstanceDestroyed event",
4+
"packageName": "react-native-windows",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}

vnext/Microsoft.ReactNative/ReactHost/ReactInstanceWin.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,12 @@ ReactInstanceWin::ReactInstanceWin(
258258
m_whenDestroyedResult =
259259
m_whenDestroyed.AsFuture().Then<Mso::Executors::Inline>([whenLoaded = m_whenLoaded,
260260
onDestroyed = m_options.OnInstanceDestroyed,
261+
// If the ReactHost has been released, this
262+
// instance might be the only thing keeping
263+
// the propertyBag alive.
264+
// We want it to remain alive for the
265+
// InstanceDestroyed callbacks
266+
propBag = m_options.Properties,
261267
reactContext = m_reactContext]() noexcept {
262268
whenLoaded.TryCancel(); // It only has an effect if whenLoaded was not set before
263269
Microsoft::ReactNative::HermesRuntimeHolder::storeTo(ReactPropertyBag(reactContext->Properties()), nullptr);

0 commit comments

Comments
 (0)