Saturday, 20 June 2020

React Matirial Ui TextField Focus on Click

import React, { useState, useEffect, useRef } from "react";
import ReactDOM from "react-dom";

const FirstName = useRef(null);

<TextField
id="firstName"
className={classes.textField}
autoFocus
label="First Name"
name="FirstName"
type="text"
variant="outlined"
fullWidth
inputRef={FirstName}
InputLabelProps={{ shrink: true }}
/>

On Your Button Click Event Write this line

ReactDOM.findDOMNode(FirstName.current).focus();


React Js Focus Textbox
React Js Textbox autoFocus
React Js with TextField autoFocus
React Js Matirial UI Textbox autoFocus
React Js Matirial UI Textbox Focus on Button Click