小编Phi*_*lou的帖子

React Native Typescript Formik 在 onPress 中输入 handleSubmit

我刚刚启动了一个使用 Typescript 的 React Native 项目,并使用 Formik 来在我的应用程序中构建表单。

我做了很棒的formik 教程指南,并看到了formik 与 JS 中 RN 部分的使用。

但是,当我尝试将此示例翻译为打字稿时,我在以下位置出现了以下键入错误Button's onPress attribute

No overload matches this call.
  Overload 1 of 2, '(props: Readonly<ButtonProps>): Button', gave the following error.
    Type '(e?: FormEvent<HTMLFormElement>) => void' is not assignable to type '(ev: NativeSyntheticEvent<NativeTouchEvent>) => void'.
      Types of parameters 'e' and 'ev' are incompatible.
        Type 'NativeSyntheticEvent<NativeTouchEvent>' is not assignable to type 'FormEvent<HTMLFormElement>'.
          Types of property 'nativeEvent' are incompatible.
            Type 'NativeTouchEvent' is missing the …
Run Code Online (Sandbox Code Playgroud)

forms typescript react-native typescript-typings formik

5
推荐指数
1
解决办法
2145
查看次数