import React, { useEffect, useRef } from 'react' const Input: React.FC<{ autoFocus?: true; label: string; id: string; type: string }> = ({ label, autoFocus, id, type, }) => { const input = useRef(null) autoFocus && useEffect(() => input.current && input.current.focus(), [input]) return ( <> <label>{label}</label> <input ref={input} id={id} type={type} placeholder={label} /> </> ) } export default Input
React Autofocus
Created
Created
2021 Sep 14 7:4Tags
Tags

