gpt4 book ai didi

javascript - 错误 : Cannot resolve module 'react-dom'

转载 作者:行者123 更新时间:2023-11-30 16:31:45 25 4
gpt4 key购买 nike

使用 babel-loader 运行 webpack 时出现错误

Module not found: Error: Cannot resolve module 'react-dom'

这是我的导入语句

import ReactDOM from 'react-dom' ;

我正在使用 React 0.14.0

最佳答案

在 0.14.x 版本中,dom 渲染功能已移至 react-dom 包中以更加通用。

As we look at packages like react-native, react-art, react-canvas, and react-three, it has become clear that the beauty and essence of React has nothing to do with browsers or the DOM.

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. This paves the way to writing components that can be shared between the web version of React and React Native. We don’t expect all the code in an app to be shared, but we want to be able to share the components that do behave the same across platforms.

The react package contains React.createElement, .createClass, .Component, .PropTypes, .Children, and the other helpers related to elements and component classes. We think of these as the isomorphic or universal helpers that you need to build components.

The react-dom package has ReactDOM.render, .unmountComponentAtNode, and .findDOMNode. In react-dom/server we have server-side rendering support with ReactDOMServer.renderToString and .renderToStaticMarkup.

关于javascript - 错误 : Cannot resolve module 'react-dom' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33218472/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com