Home > front end >  How to remove focus from a React Native TextInput on button click?
How to remove focus from a React Native TextInput on button click?

Time:07-31

I have a React Native textInput and a button and I would like to remove the focus from the textInput if I were to click on the button. Would that be possible?

My TextInput looks like this:

        <TextInput
            onChangeText={onChange}
            value={searchQuery}
            placeholder="Start typing to search or add your own"
            maxLength={80}
            onFocus={() => {
                setIsInputFocused(true);
            }}
            onBlur={() => {
                setIsInputFocused(false);
                setSearchQuery('');
            }}
            blurOnSubmit={true}
        />

And then I have a pressable element:

<View onPress={() => { //remove focus from Text Input }></View>

CodePudding user response:

The Edit remove focus from a React Native TextInput on button click

  • Related