【问题标题】:TypeScript type for onLayout event in React Native?React Native 中 onLayout 事件的 TypeScript 类型?
【发布时间】:2020-07-08 08:44:24
【问题描述】:

如何在 TypeScript 中为 React Native 的 onLayout 事件指定类型?

  const handleOnLayout = (e: SomeTypeHere) => {
    // stuff
  };

  <View onLayout={handleOnLayout}>
    <Text>Hi</Text>
  </View>

【问题讨论】:

    标签: typescript react-native


    【解决方案1】:

    这个方法返回一个LayoutChangeEvent 带有这些属性{nativeEvent: { layout: {x, y, width, height}}}

    导入:

    import { LayoutChangeEvent } from "react-native";
    

    Source

    【讨论】:

      猜你喜欢
      • 2020-06-18
      • 2020-11-16
      • 2019-11-06
      • 1970-01-01
      • 2020-01-17
      • 2016-11-15
      • 2020-10-08
      • 2017-12-03
      • 2021-02-25
      相关资源
      最近更新 更多