Reputation: 593
I'm making input component in typescript for my mobile app. I'm trying to handle change of the text in text input with useState hook, so I created this:
const [password, setPassword] = useState('');
now I have a input component:
<TextInput value={password} onChangeText={(e) => setPassword(e.target.value)} />
, and I get an error which says: "property 'target' does not exist on type 'string"
Upvotes: 0
Views: 454
Reputation: 2178
onChangeText
prop takes as a parameter the input text value, so you don't need to access e.target.value
. Just use it like this:
<TextInput value={password} onChangeText={(text) => setPassword(text)} />
Upvotes: 1