react vs react DOM confusion

前端 未结 4 789
-上瘾入骨i
-上瘾入骨i 2020-12-17 20:29

I\'m using ES6 babel with react, and now for the newer version react, react DOM is not a part of it anymore. My doubt for below code is that, is it the first line require? s

4条回答
  •  甜味超标
    2020-12-17 21:28

    React has the need to separate core react code that has nothing to do with generating a web application (HTML DOM). Particularly react-native, there are a different set of packages that are required for React Native and react-dom is not one of them.

    If the react library had never split up that DOM related code, a react-native project would have core react code that would be dead weight and then need to be removed using tree shaking and dead code elimination to remove modules in which you have never imported as part of your app.

    Having react split this code up makes a lot of sense.

提交回复
热议问题