反应导航useLayoutEffect TypeScript错误

时间:2020-09-03 15:17:24

标签: react-navigation

我要完全按照React Navigation docs中的说明添加标题按钮。

React.useLayoutEffect(() => {
    navigation.setOptions({
      headerRight: () => (
        <Button onPress={() => setCount(c => c + 1)} title="Update count" />
      ),
    });
  }, [navigation]);

得到打字稿错误:

Argument of type '{ headerRight: () => JSX.Element; }' is not assignable to parameter of type 'Partial<BottomTabNavigationOptions>'.
  Object literal may only specify known properties, and 'headerRight' does not exist in type 'Partial<BottomTabNavigationOptions>'

任何想法为何以及如何解决?

0 个答案:

没有答案