在创建用于将数据传递到反应导航的上一个屏幕的逻辑时,TS皮棉触发错误

时间:2020-04-14 08:45:33

标签: reactjs typescript react-native tslint

下面是从react-navigation文档中摘录的代码片段,其中介绍了如何将数据传递到上一个屏幕。

  React.useEffect(() => {
    if (route.params?.post) {
      // Post updated, do something with `route.params.post`
      // For example, send the post to the server
       console.log(route.params.post);
    }
  }, [route.params?.post]);

一切正常,但是出现以下错误。

Property 'post' does not exist on type 'object'.

如何清除此错误?

0 个答案:

没有答案