/
githubmr
/
facebook-react-native
Обзор
Документация
Войти
/
githubmr
/
facebook-react-native
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
main
packages/react-native/React/Fabric/Mounting/ComponentViews/Root/RCTRootComponentView.mm
55 строк
1 KB
Samuel Susla
only trigger RCTContentDidAppearNotification when content appears (#43823)
04 апр 2024, 15:52
04 апр 2024, 15:52
c7d9571
Код
Авторство
О чём код?
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ #import "RCTRootComponentView.h" #import <React/RCTRootView.h> #import <react/renderer/components/root/RootComponentDescriptor.h> #import <react/renderer/components/root/RootProps.h> #import "RCTConversions.h" using namespace facebook::react; @implementation RCTRootComponentView { BOOL _contentHasAppeared; } - (instancetype)initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { _props = RootShadowNode::defaultSharedProps(); _contentHasAppeared = NO; } return self; } #pragma mark - RCTComponentViewProtocol - (void)prepareForRecycle { [super prepareForRecycle]; _contentHasAppeared = NO; } - (void)mountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index { [super mountChildComponentView:childComponentView index:index]; if (!self->_contentHasAppeared) { self->_contentHasAppeared = YES; dispatch_async(dispatch_get_main_queue(), ^{ [[NSNotificationCenter defaultCenter] postNotificationName:RCTContentDidAppearNotification object:self]; }); } } + (ComponentDescriptorProvider)componentDescriptorProvider { return concreteComponentDescriptorProvider<RootComponentDescriptor>(); } @end