Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

Property 'propTypes' does not exist on type 'typeof TextInput'

$
0
0

I am creating a react-native component using Typescript for the first time. And I get this following error in line 51: Property 'propTypes' does not exist on type 'typeof TextInput

Similar topics didn't help me. Does someone have an idea? Thanks

import React from "react";import { View, TextInput, StyleSheet, Text } from "react-native";import PropTypes from "prop-types";export type InputProps = {    label: any;    inputStyle: any;    containerStyle: any;    touched: any;    error: any;};const Input = ({  label,  inputStyle,  containerStyle,  touched,  error,  ...props}: Partial <InputProps>) => {  return (<View style={containerStyle}><Text>{label}</Text><TextInput style={inputStyle} {...props} /><Text style={styles.errorInput}>{touched && error}</Text></View>  );};const styles = StyleSheet.create({  containerStyle: {    marginVertical: 5,  },  input: {    borderBottomWidth: 1,    minHeight: 40,    padding: 10,  },  errorInput: { color: "red", fontSize: 12 },});const stylePropsType = PropTypes.oneOfType([  PropTypes.arrayOf(PropTypes.object),  PropTypes.object,]);Input.propTypes = {  inputStyle: stylePropsType,  containerStyle: stylePropsType,  ...TextInput.propTypes, // I have an error: "Property 'propTypes' does not exist on type 'typeof TextInput'.ts(2339)"};Input.defaultProps = {  inputStyle: styles.input,  containerStyle: styles.containerStyle,  touched: false,  error: null,};export default Input;

Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>