File tree Expand file tree Collapse file tree 1 file changed +16
-7
lines changed Expand file tree Collapse file tree 1 file changed +16
-7
lines changed Original file line number Diff line number Diff line change @@ -38,29 +38,38 @@ - (instancetype)initWithFrame:(CGRect)frame
3838
3939- (void )mountChildComponentView : (UIView<RCTComponentViewProtocol> *)childComponentView index : (NSInteger )index
4040{
41- [super mountChildComponentView: childComponentView index: index];
42-
4341 // Only use the first child as the menu trigger
4442 if (index == 0 ) {
45- // Remove old child view if exists
46- if (_childView) {
47- [_childView removeFromSuperview ];
43+ // Clean up old child view if exists
44+ if (_childView && _childView != childComponentView) {
45+ // Remove from our manual tracking without calling removeFromSuperview
46+ // since React will handle the view hierarchy cleanup
4847 _childView = nil ;
48+ _menuButton = nil ;
4949 }
5050
5151 _childView = (UIView *)childComponentView;
52+ }
53+
54+ // Let React handle the mounting first
55+ [super mountChildComponentView: childComponentView index: index];
56+
57+ // Setup menu trigger after React has properly mounted the view
58+ if (index == 0 ) {
5259 [self setupChildViewAsMenuTrigger: _childView];
5360 }
5461}
5562
5663- (void )unmountChildComponentView : (UIView<RCTComponentViewProtocol> *)childComponentView index : (NSInteger )index
5764{
58- [super unmountChildComponentView: childComponentView index: index];
59-
65+ // Clean up our references before React unmounts
6066 if (index == 0 && _childView == childComponentView) {
6167 _childView = nil ;
6268 _menuButton = nil ;
6369 }
70+
71+ // Let React handle the unmounting
72+ [super unmountChildComponentView: childComponentView index: index];
6473}
6574
6675- (void )setupChildViewAsMenuTrigger : (UIView *)childView
You can’t perform that action at this time.
0 commit comments