Skip to content
This repository has been archived by the owner on Apr 5, 2021. It is now read-only.

ReactDom is not defined #46

Open
Dongd0825 opened this issue Jun 12, 2019 · 1 comment
Open

ReactDom is not defined #46

Dongd0825 opened this issue Jun 12, 2019 · 1 comment

Comments

@Dongd0825
Copy link

hello everyone, i have a question that i imort react and set externals, but also has error
import React from 'react'
import ReactDom from 'react-dom'

new HtmlWebpackExternalsPlugin({
externals: [{
module: 'react',
entry: 'https://11.url.cn/now/lib/16.2.0/react.min.js',
global: 'React',
},
{
module: 'react-dom',
entry: 'https://11.url.cn/now/lib/16.2.0/react-dom.min.js',
global: 'ReactDom',
}],
})

but also console error

external "ReactDom":1 Uncaught ReferenceError: ReactDom is not defined
at Object. (external "ReactDom":1)
at n (bootstrap:19)
at Module. (index.js:89)
at n (bootstrap:19)
at bootstrap:83
at bootstrap:83

@mmiller42
Copy link
Owner

Change global: 'ReactDom' to global: 'ReactDOM'. The compiled version of react-dom exports a global object called ReactDOM.

You can continue to import it as ReactDom.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants