diff --git a/packages/taro-router-rn/src/rootNavigation.ts b/packages/taro-router-rn/src/rootNavigation.ts index 082ffe05dfbf..5482d1af5994 100644 --- a/packages/taro-router-rn/src/rootNavigation.ts +++ b/packages/taro-router-rn/src/rootNavigation.ts @@ -3,7 +3,7 @@ import { NavigationContainerRef, StackActions } from '@react-navigation/native' import { camelCase } from 'lodash' import * as React from 'react' -import { getTabBarPages, handleUrl, setTabInitRoute, updateCurrentJumpUrl, updateJumpAnimate } from './utils/index' +import { getTabBarPages, handleUrl, setTabInitRoute, updateCurrentJumpUrl } from './utils/index' import { BaseOption, CallbackResult } from './utils/types' @@ -56,12 +56,10 @@ export function navigate (option: NavigateOption | NavigateBackOption, method: N routeParam = handleUrl(path) updateCurrentJumpUrl(path) } - updateJumpAnimate(true) try { if (method === 'navigateTo') { navigationRef.current?.dispatch(StackActions.push(routeParam.pageName, routeParam.params)) } else if (method === 'redirectTo') { - updateJumpAnimate(false) navigationRef.current?.dispatch(StackActions.replace(routeParam.pageName, routeParam.params)) } else if (method === 'switchTab' || (method === 'reLaunch' && isTabPage(path))) { const states = navigationRef.current?.getRootState() diff --git a/packages/taro-router-rn/src/router.tsx b/packages/taro-router-rn/src/router.tsx index 28693ecfcb53..87e859a5597b 100644 --- a/packages/taro-router-rn/src/router.tsx +++ b/packages/taro-router-rn/src/router.tsx @@ -8,7 +8,7 @@ import React from 'react' import { StyleProp, ViewStyle } from 'react-native' import { navigationRef } from './rootNavigation' -import { getCurrentJumpUrl, getTabInitRoute, getTabItemConfig, getTabVisible, handleUrl, hasJumpAnimate, setTabConfig } from './utils/index' +import { getCurrentJumpUrl, getTabInitRoute, getTabItemConfig, getTabVisible, handleUrl, setTabConfig } from './utils/index' import BackButton from './view/BackButton' import HeadTitle from './view/HeadTitle' import CustomTabBar from './view/TabBar' @@ -407,11 +407,7 @@ function createTabNavigate (config: RouterConfig, options: RouterOption) { detachInactiveScreens={false} {...stackProps} // @ts-ignore - screenOptions={() => ({ - ...screenOptions, - animation: hasJumpAnimate() ? 'default' : 'none', - animationEnabled: !!hasJumpAnimate() - })} + screenOptions={screenOptions} initialRouteName={getInitRouteName(config)} > ({ - ...screenOptions, - animation: hasJumpAnimate() ? 'default' : 'none', - animationEnabled: !!hasJumpAnimate() - })} + screenOptions={screenOptions} initialRouteName={getInitRouteName(config)} >{pageList.map(item => { const initParams = getInitParams(config, item.name) diff --git a/packages/taro-router-rn/src/utils/index.ts b/packages/taro-router-rn/src/utils/index.ts index 0c618850908f..ee50952931bb 100644 --- a/packages/taro-router-rn/src/utils/index.ts +++ b/packages/taro-router-rn/src/utils/index.ts @@ -122,17 +122,6 @@ export function handleUrl (url: string): Record { } } -export function hasJumpAnimate () :boolean{ - if (globalAny.__taroJumpAnimate === false){ - return false - } - return true -} - -export function updateJumpAnimate (needAnimate: boolean){ - globalAny.__taroJumpAnimate = needAnimate -} - export function updateCurrentJumpUrl (path: string){ globalAny.__taroJumpUrl = path }