Managing Focus in React Chris Westbrook on August 04, 2019 There are times when you may wish to set focus to a specific element in your react component, such as when the component first mounts, or perhaps a... Read full post Collapse Expand Sung M. Kim Sung M. Kim Sung M. Kim Follow Exploring the world of TypeScript, React & Node Location NYC - the Big 🍎 Education SUNY Stony Brook Joined Aug 5, 2017 • Aug 5 '19 Dropdown menu Copy link Hide Thank you for the easy-to-digest post, Chris. May I ask why you've used createRef over useRef? I've never done focus management thus not sure if createRef is preferred. Collapse Expand Chris Westbrook Chris Westbrook Chris Westbrook Follow I am a blind web developer currently looking for work. I am familiar with react/nextjs/remix, firebase/supabase, sql, mssql, etc. Email westbchris@gmail.com Location Williamsport, Pennsylvania Education Bachelors Degree Information Technology Work unemployed Joined Feb 17, 2019 • Aug 6 '19 Dropdown menu Copy link Hide No reason, I think I saw react.createRef somewhere and forgot about useRef. I have updated the post since useRef is more consistent. Thanks so much for the feedback. Collapse Expand Nishchith Rao Nishchith Rao Nishchith Rao Follow A mechanical engineering student trying to get along with the Developers!!! Email devmonk4@gmail.com Location India Work Student at Malnad College of Engineering,Hassan Joined Mar 15, 2020 • Aug 15 '20 Dropdown menu Copy link Hide I tried with useRef..it does not seem to work...The current value is still null..Its not updated..Any solutions?? Thank you!! Collapse Expand Rafael Rafael Rafael Follow Hi! I'm a front-end with one year of experience, and I'm intersted in learn more about it. Joined Nov 6, 2021 • Nov 12 '21 Dropdown menu Copy link Hide I don't know why, but refName.current.focus() just doesn't give me any visual result. Collapse Expand Yerkebulan Yerkebulan Yerkebulan Follow Joined Apr 17, 2022 • Apr 19 '22 Dropdown menu Copy link Hide hi Collapse Expand Yerkebulan Yerkebulan Yerkebulan Follow Joined Apr 17, 2022 • Apr 19 '22 Dropdown menu Copy link Hide /// Collapse Expand Yerkebulan Yerkebulan Yerkebulan Follow Joined Apr 17, 2022 • Apr 17 '22 Dropdown menu Copy link Hide php Collapse Expand Yerkebulan Yerkebulan Yerkebulan Follow Joined Apr 17, 2022 • Apr 18 '22 Dropdown menu Copy link Hide test Collapse Expand Yerkebulan Yerkebulan Yerkebulan Follow Joined Apr 17, 2022 • Apr 17 '22 Dropdown menu Copy link Hide PHP Collapse Expand Yerkebulan Yerkebulan Yerkebulan Follow Joined Apr 17, 2022 • Apr 19 '22 Dropdown menu Copy link Hide gg Collapse Expand Yerkebulan Yerkebulan Yerkebulan Follow Joined Apr 17, 2022 • Apr 19 '22 Dropdown menu Copy link Hide hh Collapse Expand Yerkebulan Yerkebulan Yerkebulan Follow Joined Apr 17, 2022 • Apr 19 '22 Dropdown menu Copy link Hide ddd Collapse Expand Yerkebulan Yerkebulan Yerkebulan Follow Joined Apr 17, 2022 • Apr 18 '22 Dropdown menu Copy link Hide test Code of Conduct • Report abuse For further actions, you may consider blocking this person and/or reporting abuse
Thank you for the easy-to-digest post, Chris.
May I ask why you've used
createRef
overuseRef
? I've never done focus management thus not sure ifcreateRef
is preferred.No reason, I think I saw react.createRef somewhere and forgot about useRef. I have updated the post since useRef is more consistent. Thanks so much for the feedback.
I tried with useRef..it does not seem to work...The current value is still null..Its not updated..Any solutions??
Thank you!!
I don't know why, but refName.current.focus() just doesn't give me any visual result.
hi
///
php
test
PHP
gg
hh
ddd
test