()
| 1 | import { useRef } from 'react'; |
| 2 | |
| 3 | export const FocusScreen = () => { |
| 4 | |
| 5 | const inputRef = useRef(); |
| 6 | |
| 7 | const onClick = () => { |
| 8 | // document.querySelector('input').select(); |
| 9 | // console.log(inputRef); |
| 10 | inputRef.current.select(); |
| 11 | } |
| 12 | |
| 13 | |
| 14 | return ( |
| 15 | <> |
| 16 | <h1>Focus Screen</h1> |
| 17 | <hr /> |
| 18 | |
| 19 | <input |
| 20 | ref={ inputRef } |
| 21 | type="text" |
| 22 | placeholder="Ingrese su nombre" |
| 23 | className="form-control" |
| 24 | /> |
| 25 | |
| 26 | <button |
| 27 | className="btn btn-primary mt-2" |
| 28 | onClick={ onClick } |
| 29 | > |
| 30 | Set focus |
| 31 | </button> |
| 32 | |
| 33 | </> |
| 34 | ) |
| 35 | } |
nothing calls this directly
no outgoing calls
no test coverage detected