Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 反应导航和打字脚本。财产';getScreen';类型中缺少_Reactjs_Typescript_React Navigation - Fatal编程技术网

Reactjs 反应导航和打字脚本。财产';getScreen';类型中缺少

Reactjs 反应导航和打字脚本。财产';getScreen';类型中缺少,reactjs,typescript,react-navigation,Reactjs,Typescript,React Navigation,使用TypeScript和react导航可获得以下TypeScript问题: Property 'Principles' is incompatible with index signature. Type '{ screen: (props: any) => Element; path: string; }' is not assignable to type 'NavigationRouteConfig'. Type '{ screen: (props: any

使用TypeScript和react导航可获得以下TypeScript问题:

  Property 'Principles' is incompatible with index signature.
    Type '{ screen: (props: any) => Element; path: string; }' is not assignable to type 'NavigationRouteConfig'.
      Type '{ screen: (props: any) => Element; path: string; }' is not assignable to type '{ navigationOptions?: any; path?: string; } & { getScreen: () => NavigationComponent; }'.
        Type '{ screen: (props: any) => Element; path: string; }' is not assignable to type '{ getScreen: () => NavigationComponent; }'.
          Property 'getScreen' is missing in type '{ screen: (props: any) => Element; path: string; }'.
以下是“我的导航器”中的代码:

const MainNavigator: NavigationContainer = StackNavigator({
    Principles: {
      screen: props => <WebViewModal source={{ uri: MY_URI }} {...props} />,
      path: 'principles',
    },
})

如何解决此typescript问题?

查看react导航的index.d.ts,我发现您可以执行以下操作:

Principles: {
  getScreen: () => props => <WebViewModal source={{ uri: MY_URI }} {...props} />,
  path: 'principles',
},
原则:{
getScreen:()=>道具=>,,
路径:"原则",,
},

然而,当我看到这个错误时,我也能够摆脱它,而不改变代码,只是简单地删除了node_模块和warn.lock,然后再次运行warn安装。

我看到了同样的情况。真奇怪。
Principles: {
  getScreen: () => props => <WebViewModal source={{ uri: MY_URI }} {...props} />,
  path: 'principles',
},