1const emailInputRef = React.useRef(null);
2
3React.useEffect(()=>{
4 emailInputRef.current.focus();
5}, []);
6
7<input type="email" name="email" ref={this.emailInputRef} />
1<!DOCTYPE html>
2<html>
3 <head> </head>
4 <body>
5 <label>
6 Title
7 <input type="text" autofocus value="Untitled" />
8 </label>
9 </body>
10</html>