【发布时间】:2020-10-13 23:49:03
【问题描述】:
我正在努力正确扩展 react-native-paper 组件。我做错了什么或如何正确做?实际上,我对 Typescript 并不完全陌生,但我一直在努力解决这个问题:
// TextInput.tsx
import React from "react";
import { TextInput as PaperTextInput } from "react-native-paper";
import { TextInputProps } from "react-native-paper/lib/typescript/src/components/TextInput/TextInput";
interface MyTextInputProps extends TextInputProps {}
const MyTextInput: React.FC<MyTextInputProps> = (props) => {
return <PaperTextInput {...props} />;
};
export default MyTextInput;
// Usage:
<TextInput mode="outlined" style={styles.input} label="Email" />
我得到这个错误:
类型'{ mode: "outlined"; 中缺少属性'theme';风格:{ alignSelf:“伸展”; };标签:字符串; }' 但在 'MyTextInputProps' 类型中是必需的
【问题讨论】:
标签: reactjs typescript react-native