React Native: NavigationExperimental. replace()的正确逻辑是什么?

React Native: What is the proper and correct .replace() logic for NavigationExperimental?

本文关键字:是什么 Native NavigationExperimental replace React      更新时间:2023-09-26

在React Native中,目前我为NavigationExperimental的.push()和.pop()设置了以下代码:

case PUSH_ROUTE:
  if (state.routes[state.index].key === (action.route && action.route.key)) return state
return NavigationStateUtils.push(state, action.route)
case POP_ROUTE:
  if (state.index === 0 || state.routes.length === 1) return state
  return NavigationStateUtils.pop(state)

我试着搜索,但找不到正确的逻辑来实现。replace()。实现.replace()逻辑的正确方法是什么?

提前感谢!

navigationstateutil已经有两个替换函数。源代码见https://github.com/facebook/react-native/blob/master/Libraries/NavigationExperimental/NavigationStateUtils.js