Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@

using namespace facebook::react;

static const std::shared_ptr<const NativeScriptUIViewProps>& NativeScriptUIViewDefaultProps() {
static const auto defaultProps = std::make_shared<const NativeScriptUIViewProps>();
return defaultProps;
}

static BOOL NativeScriptFabricViewIsDescendantOfView(UIView* view, UIView* ancestor) {
UIView* current = view;
while (current != nil) {
Expand Down Expand Up @@ -78,8 +83,7 @@ @implementation NativeScriptUIViewComponentView {

- (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
static const auto defaultProps = std::make_shared<const NativeScriptUIViewProps>();
_props = defaultProps;
_props = NativeScriptUIViewDefaultProps();

_containerView = [[NativeScriptUIView alloc] initWithFrame:self.bounds];
_containerView.hostReadyDelegate = self;
Expand Down Expand Up @@ -190,7 +194,12 @@ - (UIView*)hitTest:(CGPoint)point withEvent:(UIEvent*)event {
}

- (void)updateProps:(Props::Shared const&)props oldProps:(Props::Shared const&)oldProps {
const auto oldViewProps = std::static_pointer_cast<const NativeScriptUIViewProps>(_props);
// Diff against oldProps, not _props: React Native leaves _props untouched on
// recycle, while prepareForRecycle clears the container, so a recycled view
// mounted with its previous handle would otherwise never attach it.
const auto oldViewProps =
oldProps ? std::static_pointer_cast<const NativeScriptUIViewProps>(oldProps)
: NativeScriptUIViewDefaultProps();
const auto newViewProps = std::static_pointer_cast<const NativeScriptUIViewProps>(props);
const std::string oldNativeViewHandle = oldViewProps->nativeViewHandle;
const std::string newNativeViewHandle = newViewProps->nativeViewHandle;
Expand Down
Loading