@Dhiraj’s answer is correct, and for convenience you can use the autoFocus prop to have an input automatically focus when mounted:
<input autoFocus name=...
Note that in jsx it’s autoFocus
(capital F) unlike plain old html which is case-insensitive.
More Related Contents:
- Unable to access React instance (this) inside event handler [duplicate]
- Why do we need middleware for async flow in Redux?
- Why is my React component is rendering twice?
- ReactJS: Maximum update depth exceeded error
- Wrong React hooks behaviour with event listener
- What does three dots do in ReactJS [duplicate]
- Why is my onClick being called on render? – React.js
- what is right way to do API call in react js?
- REACT – toggle class onclick
- How to display binary data as image in React?
- ES6 modules implementation, how to load a json file
- Sending Request body for GET method in AXIOS throws error
- Recommended way of making React component/div draggable
- React: why child component doesn’t update when prop changes
- How to store Configuration file and read it using React
- React: trigger onChange if input value is changing by state?
- Is store.dispatch in Redux synchronous or asynchronous
- Difference between declarative and imperative in React.js?
- How do I setState for nested object?
- First Load JS shared by all is rather heavy in next.js
- Getting an error “A non-serializable value was detected in the state” when using redux toolkit – but NOT with normal redux
- React eslint error missing in props validation
- useEffect is running twice on mount in React
- React – useState – why setTimeout function does not have latest state value?
- How to create a protected route with react-router-dom?
- “You may need an additional loader to handle the result of these loaders.”
- Only numbers. Input number in React
- Disable chrome react DevTools for production
- You’re importing a component that needs useState. It only works in a Client Component, but none of its parents are marked with “use client”
- How can I redirect in React Router v6?