Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the differences between react and reactdom

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces "what are the differences between react and reactdom". In daily operation, I believe many people have doubts about the differences between react and reactdom. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the questions of "what are the differences between react and reactdom?" Next, please follow the editor to study!

The difference between react and reactdom is that ReactDom only does operations related to the browser or DOM, such as "ReactDOM.findDOMNode ()" operations, while react is responsible for related operations other than browsers and DOM, and ReactDom is part of React.

The operating environment of this tutorial: Windows10 system, react17.0.1 version, Dell G3 computer.

What's the difference between react and reactdom?

ReactDom only does operations related to the browser or DOM, such as ReactDOM.render () and ReactDOM.findDOMNode (). If it is server-side rendering, you can ReactDOM.renderToString (). React can not only deal with Web pages through ReactDOM, but also be used in server-side SSR, mobile ReactNative and desktop Electron.

React did not have ReactDOM before v0.14, and all functions are included in React. Starting from v0.14 (2015-10), React is split into React and ReactDOM. Why separate React from ReactDOM? Because of ReactNative. React contains only the common core parts of Web and Mobile, those responsible for Dom operations are assigned to ReactDOM, and those responsible for Mobile are included in ReactNative.

ReactDom is part of React. ReactDOM is the glue between React and DOM, commonly used to define a single component, or in combination with ReactDOM.findDOMNode (). More importantly, the ReactDOM package has allowed developers to remove unnecessary code added by the React package and move it to a more appropriate repository.

E.g:

React code on Web side

Import React from 'react';import ReactDOM from' react-dom';const App = () = > (Hello React) ReactDom.render (, document.getElementById ('root'))

The ReactNative code of the mobile:

Import React from 'react';import {Text, View} from' react-native';const WelcomeScreen = () = > (Hello ReactNative)

The same thing is that they all need import React from 'react'.

Web applications need import ReactDOM from 'react-dom'.

Mobile application requires import {Text, View} from 'react-native'

At this point, the study on "what is the difference between react and reactdom" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report