If you’ve ever worked with React to create an amazing web user interface, then you must’ve used React-DOM. In case, you’re coming from the React-Native background, React-DOM might sound alien to you. For a long time, I used to think they’re part of each other, only pondering occasionally while waiting for react dev server to start, why do we import React and React-DOM separately? I searched around and got some answers that I would like to share.
So React and React-DOM both are developed by the same team and up until React V0.14 React-DOM was shipped inside React package.
So coming to the crux of this article, i.e. the difference between React and React-DOM :
React-DOM: React-DOM is a complimentary library to React which glues React to the browser DOM
In a nutshell, Whenever we use component, classes, elements, etc. We’re using React and whenever we use methods like
findDOMNode() we’re using React-DOM.
Why did the React team decide to split React and React-DOM into two different libraries?
Because React-DOM binds the idea of React to a web browser. And ideally, React has nothing to do with a browser or web for that matter. That’s why we’re seeing tools and frameworks like React-Native, React-Three being developed. These tools and frameworks don’t use React-DOM, but they do in fact use the idea behind React.
This is what the team had to say when they were splitting these two libraries
To make this more clear and to make it easier to build more environments that React can render to, we’re splitting the main react package into two: react and react-dom.
Why should I care?
Well, during an interview questions like these let me know how well the candidate knows his technology. Is the candidate following the team that created the library he/she everyday uses? Is he keeping up with the latest changes in those libraries and why those changes are taking place?
You can amaze interviewers and your peers/co-workers with such intricate details.
That’s all folks
Hope this article provided some value to your dev career.