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

Props in custom components React native + Typescript

$
0
0

I've got a problem with access to onChangeText in my custom component.Here is the code of my component:

import React from 'react';import {TextInput, StyleSheet} from 'react-native';type Props={   style:any}const Input = (props:Props) =>{    return <TextInput {...props} style = {{...styles.input, ...props.style}} blurOnSubmit autoCorrect = {false} keyboardType = "number-pad" maxLength = {2} />}const styles = StyleSheet.create({    input:{        height:30,        borderBottomColor: 'grey',        borderBottomWidth: 1,        marginVertical: 10    }})export default Input;`

And here is the part of code in another file where i'm using it:

<Input style = {styles.input} onChangeText = {numberInputHandler} value = {enteredValue} />

OnChangeText is underlined and the error is Property 'onChangeText' does not exist on type 'IntrinsicAttributes & Props'. I see in a tutorial that after typing {...props} in my custom component inside there is access to its props, but guy is writing in js and I'm in in ts. Thanks for help!


Viewing all articles
Browse latest Browse all 6287

Trending Articles



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