我可以在 React Navigation 6 中将函数从 parent 传输到 child 吗?

Can I transmit a func from parent to child in reactnavigation 6?

祝你有愉快的一天。

我可以在 reactnavigation 6 中将函数从 parent 传输到 child 吗?

也许像 这个:

onPress={function =>
 navigation.navigate({
  name: LANGUAGES.label_people_component,
  params: function,
  merge: true,
 })
}

谢谢大家。

如前所述here,

We recommend that the params you pass are JSON-serializable. That way, you'll be able to use state persistence and your screen components will have the right contract for implementing deep linking.

React Navigation 参数的工作方式类似于 6.x 网站中的查询参数 我相信,现在执行此操作的理想方法是使用具有单一信息源的上下文 API。

如果您有大量存储和操作来操作它们,您还可以使用状态管理库,例如 redux or mobx