Files
react-native/React/Views/RCTWeakViewHolder.h
T
Peter Argany 4efdf264d1 Introducing RCTWeakViewHolder [4/n]
Summary:
Problem: In paper, there is a handy API called `[uiManager viewForReactTag:]`. Fabric does not have this mapping. The Fabric interop layer still relies on this Paper mapping.

Solution: As a workaround, re-create this mapping in the Fabric interop layer. Therefore, whenever Fabric interop layer asks a paper view manager to create a view, store a weak reference to the view in a `NSMapTable`. NSMapTable allows us to customize the strong/weak relationship. I've added a comment explaining that `RCTWeakViewHolder` only needs to be used for this special circumstance.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D27438899

fbshipit-source-id: 94663ef06479a8c863ce58b0f36d42109fa1c4f3
2021-03-31 16:39:02 -07:00

20 lines
617 B
Objective-C

/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/*
* THIS IS A HACK
* This protocol should only be used for Paper ViewManagers which need to
* use the Fabric Interop layer, and also need to reference their created
* views. This protocol allows the view manager to store a weak reference to
* any created views. It will not affect view lifecycle in any way.
*/
@protocol RCTWeakViewHolder
@property (nonatomic, strong) NSMapTable<NSNumber *, UIView *> *weakViews;
@end