NA +91-8727899942 thecoderjob@gmail.com

CHAPTER - 12

How get text Input value || Handling text input value?

Handling text input in React Native involves using the TextInput component provided by React Native. You can capture the value entered by the user and use it for various purposes like form submissions, search functionalities, etc.

Here's is the Code !!

import React, { useState } from 'react';
import { View, TextInput, Button, Alert } from 'react-native';

const TextInputExample = () => {
  const [textInputValue, setTextInputValue] = useState('');

  const handleTextInputChange = (text) => {
    setTextInputValue(text);
  };

  const handleSubmit = () => {
    Alert.alert('Entered Text', textInputValue);
  };

  return (
    <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
      <TextInput
        style={{ height: 40, width: 200, borderColor: 'gray', borderWidth: 1, padding: 10 }}
        placeholder="Enter text..."
        onChangeText={handleTextInputChange}
        value={textInputValue}
      />
      <Button title="Submit" onPress={handleSubmit} />
    </View>
  );
};

export default TextInputExample;

Chapter 11

Style in React Native || what are the different style type.

Previous chapter

Get In Touch

NA

thecoderjob@gmail.com

+91-8727899942

Popular Links

© www.thecoderjob.com. All Rights Reserved.               Designed by HTML Codex