mirror of
https://github.com/status-im/react-native.git
synced 2025-02-25 23:55:23 +00:00
RCTAllocatedRootViewTag was moved to RCTUIManagerUtils
Summary: This logic was decoupled from RCTRootView to make it reusable. Reviewed By: javache Differential Revision: D6214785 fbshipit-source-id: e7419be03ba0e20d95b47c11e41789636aa6e916
This commit is contained in:
parent
75d62bf0a8
commit
be6976d6fa
@ -24,6 +24,7 @@
|
||||
#import "RCTRootContentView.h"
|
||||
#import "RCTTouchHandler.h"
|
||||
#import "RCTUIManager.h"
|
||||
#import "RCTUIManagerUtils.h"
|
||||
#import "RCTUtils.h"
|
||||
#import "RCTView.h"
|
||||
#import "UIView+React.h"
|
||||
@ -243,7 +244,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder)
|
||||
* NOTE: Since the bridge persists, the RootViews might be reused, so the
|
||||
* react tag must be re-assigned every time a new UIManager is created.
|
||||
*/
|
||||
self.reactTag = [_bridge.uiManager allocateRootTag];
|
||||
self.reactTag = RCTAllocateRootViewTag();
|
||||
}
|
||||
return super.reactTag;
|
||||
}
|
||||
@ -396,14 +397,3 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder)
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation RCTUIManager (RCTRootView)
|
||||
|
||||
- (NSNumber *)allocateRootTag
|
||||
{
|
||||
NSNumber *rootTag = objc_getAssociatedObject(self, _cmd) ?: @1;
|
||||
objc_setAssociatedObject(self, _cmd, @(rootTag.integerValue + 10), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
||||
return rootTag;
|
||||
}
|
||||
|
||||
@end
|
||||
|
@ -7,7 +7,7 @@
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import <React/RCTAssert.h>
|
||||
#import <React/RCTDefines.h>
|
||||
@ -99,3 +99,8 @@ RCT_EXTERN void RCTUnsafeExecuteOnUIManagerQueueSync(dispatch_block_t block);
|
||||
*/
|
||||
#define RCTAssertUIManagerQueue() RCTAssert(RCTIsUIManagerQueue() || RCTIsPseudoUIManagerQueue(), \
|
||||
@"This function must be called on the UIManager queue")
|
||||
|
||||
/**
|
||||
* Returns new unique root view tag.
|
||||
*/
|
||||
RCT_EXTERN NSNumber *RCTAllocateRootViewTag(void);
|
||||
|
@ -9,6 +9,8 @@
|
||||
|
||||
#import "RCTUIManagerUtils.h"
|
||||
|
||||
#import <libkern/OSAtomic.h>
|
||||
|
||||
#import "RCTAssert.h"
|
||||
|
||||
char *const RCTUIManagerQueueName = "com.facebook.react.ShadowQueue";
|
||||
@ -93,3 +95,10 @@ void RCTUnsafeExecuteOnUIManagerQueueSync(dispatch_block_t block)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NSNumber *RCTAllocateRootViewTag()
|
||||
{
|
||||
// Numbering of these tags goes from 1, 11, 21, 31, ..., 100501, ...
|
||||
static int64_t rootViewTagCounter = -1;
|
||||
return @(OSAtomicIncrement64(&rootViewTagCounter) * 10 + 1);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user