2015-10-19 56 views
1

與巴貝爾裝載機運行的WebPack當我收到提示錯誤:無法解析模塊 '反應-DOM'

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

這裏是我的import語句

import ReactDOM from 'react-dom' ; 

我使用的陣營0.14 .0

+1

你能運行併發布命令npm ls的結果嗎? –

+1

升級後是否安裝了react-dom軟件包? –

+0

[email protected]當我運行npm ls時出現在列表中 –

回答

2

在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.

相關問題