I am trying to make Search Bar. I want user to type something in TextInput
and when user press 'Enter' I want to call my function.
<TextInput
//here when user press enter call function()
style={styles.searchStyle}
allowFontScaling={false}
placeholder="Search"
onChangeText={(val) => {setSearch(val)}}
/>
I tried onSubmitEditing
but it doesn't work.
import React, { Component } from 'react' import {TextInput} from 'react-native'
const Trial =()=>{
const onSubmitted=()=>{
console.log('Submitted')
}
return(
<TextInput
//here when user press enter call function()
// style={styles.searchStyle}
allowFontScaling={false}
placeholder="Search"
onSubmitEditing={()=>onSubmitted()}
/>
)
}
export default Trial
onSubmitEditing it works fine, I hope it would be helpful for you