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

Send / submit button not calling linked function in React Native

$
0
0

The button in the example below doesn't seem to be calling the function linked to it when the keyboard is up / TextInput is on focus. It does work when the keyboard is down, though.

My best guess is that when the TextInput is on focus, the first press on the button is being used to shift focus away from the TextInput (although, not typical behaviour) and any subsequent presses on the button fire up the linked function. Which may also explain why the function does get called on every press event when the keyboard is down.

function msgInputHandler() {    console.log("Test");  }<View style={styles.msgInputContainer}><TextInput    placeholder="Message..."    style={[styles.search, { width: "85%" }]}  /><Pressable onPress={msgInputHandler}>        <Ionicons name="arrow-up-circle" size={40} color="orange" />       </Pressable></View>

I have removed all the state updating code from the example above, all of which is irrelevant to the problem.

The button is supposed to be pressed by the users after entering some text into the input field which should then initiate an API call. Therefore, it can be assumed that the button will only be clicked when the keyboard is up.


Viewing all articles
Browse latest Browse all 17228

Trending Articles



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