You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Wix react-native-navigation 4.2.0:关闭模态框同时切换标签页可行吗?

Wix React Native Navigation v4.2.0: Dismiss Modal + Switch Bottom Tab

Hey there! Let's break down this problem for you.

In v4.2.0 of React Native Navigation, the dismissModal method doesn't support passing bottomTabs configuration directly in its options parameter. The options object you tried to use is only intended for controlling the modal's dismissal animations and behavior—not for modifying the bottom tabs state after the modal closes. That's why your initial code didn't work.

The Fix: Switch Tabs After Dismissing the Modal

To achieve what you want, you need to trigger the tab switch once the modal has finished dismissing. Here's how to do it properly:

Option 1: Use findComponentIdForName to Target Bottom Tabs

If you know the registered name of your bottom tabs screen, you can retrieve its component ID directly:

Navigation.dismissModal(componentId, () => {
  // Replace 'YourBottomTabsScreen' with your actual bottom tabs screen name
  const bottomTabsComponentId = Navigation.findComponentIdForName('YourBottomTabsScreen');
  
  // Switch to the desired tab (index 1 in your example)
  Navigation.mergeOptions(bottomTabsComponentId, {
    bottomTabs: {
      currentTabIndex: 1
    }
  });
});

Option 2: Use getParent for More Reliability

If your modal was presented from a screen inside the bottom tabs, you can fetch the bottom tabs' component ID via the modal's parent. Note that in v4.x, getParent returns a promise, so we'll use async/await:

Navigation.dismissModal(componentId, async () => {
  // Get the parent bottom tabs component ID from the modal's originating screen
  const bottomTabsComponentId = await Navigation.getParent(componentId);
  
  Navigation.mergeOptions(bottomTabsComponentId, {
    bottomTabs: {
      currentTabIndex: 1
    }
  });
});

Either approach will ensure that the modal closes first, then the bottom tab switches to your target index.

内容的提问来源于stack exchange,提问作者Kevin Amiranoff

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.06 07:38:14