📜  反应焦点 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:15.241000             🧑  作者: Mango

代码示例2
const FocusDemo = () => {

    const [inputRef, setInputFocus] = useFocus()

    return (
        <> 
            
            
        
    )

}

const useFocus = () => {
    const htmlElRef = useRef(null)
    const setFocus = () => {htmlElRef.current &&  htmlElRef.current.focus()}

    return [ htmlElRef, setFocus ] 
}