Home > Software engineering >  How to get all props of native component when create new component with typescript interface
How to get all props of native component when create new component with typescript interface

Time:11-27

It's maybe the simple question but honestly i don’t know how to do that

For exmaple i have a custom TextInput from react native called CustomTextInput

And it will have an interface

export interface CustomTextInputI{
 customPlaceHolder:string
 style:ViewStyle
 //etc
}

And i use it like

export const CustomTextInput =(props:CustomTextInputI)=>(
    const {customPlaceHolder, style} = props
     
    return(
     <TextInput style={style}. etc />
    )
)

And use this componet like <CustomTextInput style customPlaceHolder/> BUT if i use a textInput props like secureTextEntry, it will not accecpt (of course) so how can i use my custom props plus all props of TextInput. ???

CodePudding user response:

Should work:

import { TextInputProps } from 'react-native'
   
export interface CustomTextInputI extends TextInputProps {
  • Related