MCPcopy Create free account
hub / github.com/Klerith/react-hooks / FocusScreen

Function FocusScreen

src/04-useRef/FocusScreen.jsx:3–35  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1import { useRef } from 'react';
2
3export 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}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected