0

Here I want to assign the data from textInput to variable a. How can I do it? (That is, when the user enters data in textInput, I want to assign it to variable a.)

import React, { Component } from 'react'
import { Text, View, TextInput} from 'react-native'

export default class deneme1 extends Component {
    constructor(props) {
        super(props);
        this.state = {

            a:"",
            
       };
      }
    render() {
        return (
            <View>
                <View style={styles.textinput}>
                    <TextInput
                    placeholderTextColor='white'
                    style={styles.textinputtext}
                />

                </View>
            </View>
        )
    }
}

1 Answer 1

2

You can try this one

<TextInput
 placeholder={"A Variable"}
 onChangeText={(text) => this.setState({a: text}) }
 value={this.state.a}
/>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.