{"size": 387, "ext": "js", "max_stars_repo_path": "react-hooks/src/useRef/index.js", "max_stars_repo_name": "linpeng6/op-react-learning", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "react-hooks/src/useRef/index.js", "max_issues_repo_name": "linpeng6/op-react-learning", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "react-hooks/src/useRef/index.js", "max_forks_repo_name": "linpeng6/op-react-learning", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 22.7647058824, "max_line_length": 68, "alphanum_fraction": 0.5555555556}
import React, { useRef } from 'react'

export default function Index() {
    const inputEl = useRef(null);

    const onButtonClick = ()=>{
        // `current` 指向已挂载到 DOM 上的文本输入元素
        inputEl.current.focus();
    }
    return (
        <div>
            <input ref={inputEl} type="text" />
            <button onClick={onButtonClick}>Focus the input</button>
        </div>
    )
}
