【问题标题】:Flow type for PanResponder like in examplePanResponder 的流类型,如示例
【发布时间】:2022-02-14 12:46:47
【问题描述】:

无法找到 PanResponder 的流类型,如官方 react-native 示例所示。

此处示例:https://github.com/facebook/react-native/blob/0ccedf3964b1ebff43e4631d1e60b3e733096e56/RNTester/js/examples/PanResponder/PanResponderExample.js#L17

这不起作用:

import type {
  PanResponderInstance,
} from 'react-native';

对于键入 PanResponders:

// @flow

type Props = {…};
type State = {…};
class Screen extends Component<Props, State> {
  _panresponder: PanResponderInstance
  …
}

我想使用 PanResponder 的流类型,就像上面链接的示例一样。如何从 react-native 访问 PanResponder (PanResponderInstance) 的类型?

【问题讨论】:

    标签: react-native flowtype


    【解决方案1】:
    import type {
       PanResponderInstance,
    } from 'react-native';
    

    这将适用于 react native 0.64

    【讨论】:

      【解决方案2】:

      我想通了:

      import type {
         PanResponderInstance,
      } from 'react-native/Libraries/Interaction/PanResponder';
      

      遗憾的是,这似乎是一种方法,虽然不是最理想的,但很有效。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-08-18
        • 1970-01-01
        • 2022-11-02
        • 1970-01-01
        • 2017-05-03
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多