Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

react focus

const FocusDemo = () => {

    const [inputRef, setInputFocus] = useFocus()

    return (
        <> 
            <button onClick={setInputFocus} >
               FOCUS
            </button>
            <input ref={inputRef} />
        </>
    )

}

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

    return [ htmlElRef, setFocus ] 
}
Comment

react focus

<input type="text" autoFocus />
Comment

PREVIOUS NEXT
Code Example
Javascript :: how to generate a random salt in nodejs 
Javascript :: come andare a capo su javascript 
Javascript :: console.log json shopify 
Javascript :: js find all max number indexes in array 
Javascript :: javascript Convert to Boolean Explicitly 
Javascript :: css on javascript 
Javascript :: queryselectorall in javascript to get data attribute value 
Javascript :: jquery wait for element to load 
Javascript :: react js pdf generate from html 
Javascript :: window.location.href url.action parameters 
Javascript :: javascript combine two index elements 
Javascript :: Quick Git Setup 
Javascript :: javascript is url 
Javascript :: limit html input to two decimal places 
Javascript :: how to give height through props 
Javascript :: change the position of div using javascript 
Javascript :: async await class component react 
Javascript :: print object keys 
Javascript :: args slice discord.js 
Javascript :: ref in mongoose example 
Javascript :: filter through date in mongooes 
Javascript :: codeigniter csrf token ajax 
Javascript :: condition inner populate mongoose 
Javascript :: how to kill all node processes 
Javascript :: Divide the number in js 
Javascript :: express url redirect 
Javascript :: add element into array 
Javascript :: Check for a Null or Empty String in JavaScript 
Javascript :: jquery timepicker 
Javascript :: material ui dark theme 
ADD CONTENT
Topic
Content
Source link
Name
2+3 =