r/reactjs • u/swyx • Jun 03 '18
Beginner's Thread / Easy Question (June 2018)
Hello! just helping out /u/acemarke to post a beginner's thread for June! we had over 270 comments in last month's thread! If you didn't get a response there, please ask again here! You are guaranteed a response here!
Soo... Got questions about React or anything else in its ecosystem? Stuck making progress on your app? Ask away! We’re a friendly bunch. No question is too simple.
The Reactiflux chat channels on Discord are another great place to ask for help as well.
Pre-empting the most common question: how to get started learning react?
You might want to look through /u/acemarke's suggested resources for learning React and his React/Redux links list. Also check out http://kcd.im/beginner-react.
View all comments
Show parent comment
2
u/VariadicIntegrity Jun 08 '18 edited Jun 08 '18
Not really, id's have various uses in the web. For example, the htmlFor property, aria-describedby, and autoscrolling based on the hash portion of a url.
Refs are a replacement for querying the DOM. It just so happens that lots of people tend to query the DOM by using ids.
Refs are safer though. React will only give you the ref once the element is ready.
If you try to query for a React element, it may or may not be rendered yet, and getElementById may return null.