File tree Expand file tree Collapse file tree 2 files changed +21
-4
lines changed Expand file tree Collapse file tree 2 files changed +21
-4
lines changed Original file line number Diff line number Diff line change @@ -64,9 +64,17 @@ export function registerBottomNavigation(): void {
64
64
const items = bottomNavigation . items || [ ] ; // Annoyingly, it's the consumer's responsibility to ensure there's an array there!
65
65
66
66
if ( typeof atIndex === 'undefined' || atIndex === items . length ) {
67
- bottomNavigation . items = items . concat ( child . nativeView as TabContentItem ) ;
67
+ bottomNavigation . _addChildFromBuilder ( ' items' , child . nativeView as TabContentItem ) ;
68
68
} else {
69
- bottomNavigation . items = items . slice ( ) . splice ( atIndex , 0 , child . nativeView as TabContentItem ) ;
69
+ items . forEach ( ( item ) => {
70
+ bottomNavigation . _removeView ( item ) ;
71
+ } ) ;
72
+ const itemsClone = items . slice ( ) ;
73
+ itemsClone . splice ( atIndex , 0 , child . nativeView as TabContentItem ) ;
74
+ bottomNavigation . items = itemsClone ;
75
+ itemsClone . forEach ( ( item ) => {
76
+ bottomNavigation . _addView ( item ) ;
77
+ } ) ;
70
78
}
71
79
} else if ( child . nodeRole === 'item' ) {
72
80
if ( __DEV__ ) {
Original file line number Diff line number Diff line change @@ -235,9 +235,17 @@ export function registerTabs(): void {
235
235
236
236
const items = tabs . items || [ ] ; // Annoyingly, it's the consumer's responsibility to ensure there's an array there!
237
237
if ( typeof atIndex === 'undefined' || atIndex === items . length ) {
238
- tabs . items = items . concat ( child . nativeView as TabContentItem ) ;
238
+ tabs . _addChildFromBuilder ( ' items' , child . nativeView as TabContentItem ) ;
239
239
} else {
240
- tabs . items = items . slice ( ) . splice ( atIndex , 0 , child . nativeView as TabContentItem ) ;
240
+ items . forEach ( ( item ) => {
241
+ tabs . _removeView ( item ) ;
242
+ } ) ;
243
+ const itemsClone = items . slice ( ) ;
244
+ itemsClone . splice ( atIndex , 0 , child . nativeView as TabContentItem ) ;
245
+ tabs . items = itemsClone ;
246
+ itemsClone . forEach ( ( item ) => {
247
+ tabs . _addView ( item ) ;
248
+ } ) ;
241
249
}
242
250
} else if ( child . nodeRole === 'item' ) {
243
251
if ( __DEV__ ) {
@@ -258,6 +266,7 @@ export function registerTabs(): void {
258
266
tabs . tabStrip = null ; // Anything falsy should work.
259
267
} else if ( child . nodeRole === 'items' ) {
260
268
tabs . items = ( tabs . items || [ ] ) . filter ( ( i ) => i !== child . nativeView ) ;
269
+ tabs . _removeView ( child . nativeView ) ;
261
270
} else if ( child . nodeRole === 'item' ) {
262
271
if ( __DEV__ ) {
263
272
warn ( `Unable to remove child "${ child . nativeView . constructor . name } " from <tabs> as it had the nodeRole "item"; please correct it to "items".` ) ;
You can’t perform that action at this time.
0 commit comments