0

The configuration is as follows:

class MyComponent extends Component {
    constructor(props) {
        super(props);
     
        this.inputRef = React.createRef();
    }

    ...
 
    render() {
        ...
        <TextInput style={styles.textInput}
           ...                           
           ref={this.inputRef}
        />
        ...
    }
}

Q. How to find out if TextInput has focus within a render() method?

Denis Kulagin
  • 8,472
  • 17
  • 60
  • 129

1 Answers1

1

you can check either by using this functions or by creating your custom setup by registering onBlur() and onFocus() callback functions in your textInput.

e.g.

<TextInput
          onFocus={() =>console.log("focus received" ) }
          onBlur={() => console.log("focus lost") } />