Javascript 调用时未定义React<;TinodeWeb/>;
需要帮助 我尝试在我的项目中使用tinode,我用npm I tinode webapp安装它,如下所示当我用Javascript 调用时未定义React<;TinodeWeb/>;,javascript,reactjs,chat,Javascript,Reactjs,Chat,需要帮助 我尝试在我的项目中使用tinode,我用npm I tinode webapp安装它,如下所示当我用调用它时,它给我错误未定义React 这是我的密码 import React from 'react'; import './App.css'; import TinodeWeb from 'tinode-webapp'; function App() { return ( // <div className="App"> <TinodeWeb /
import React from 'react';
import './App.css';
import TinodeWeb from 'tinode-webapp';
function App() {
return (
// <div className="App">
<TinodeWeb />
// </div>
);
}
export default App;
我的错误
我犯了错误吗?检查尝试将react放在tinode插件之前的webpack部分的第一位:[新的CopyPlugin([{from:
node\u模块/tinode sdk/umd/tinode.${mode}.js
,to:tinode.${mode}.js
},]),新的webpack.ProvidePlugin({“react:“react”,}),]@Waqasumtaz我已经尝试了所有的可能性,但仍然eror@Niraj我已经尝试将react放在第一个位置:[new webpack.ProvidePlugin({“react”:“react”,}),new CopyPlugin([{from:node_modules/tinode sdk/umd/tinode.${mode}.js,to:tinode.${mode}.js},]),]但仍然存在错误请在github中提出npm包的问题,我认为它链接到产品,或者甚至尝试使用较新版本,然后尝试使用较旧版本以实现兼容性
module: {
rules: [
{
test: /\.jsx?$/,
loaders: [
'babel-loader',
],
exclude: /node_modules/,
},
],
},
output: {
path: path.resolve(__dirname, 'umd'),
filename: `[name].${mode}.js`,
publicPath: '/umd/'
},
optimization: {
minimizer: [
// we specify a custom UglifyJsPlugin here to get source maps in production.
new UglifyJsPlugin({
cache: true,
parallel: true,
uglifyOptions: {
compress: true,
mangle: true
},
sourceMap: true
})
]
},
performance: {
maxEntrypointSize: 262144,
maxAssetSize: 262144
},
plugins: [
new CopyPlugin([
{ from: `node_modules/tinode-sdk/umd/tinode.${mode}.js`, to: `tinode.${mode}.js` },
]),
new webpack.ProvidePlugin({
"React":"react",
}),
],
externals: {
'react': 'React',
'react-dom': 'ReactDOM',
'react-intl': 'ReactIntl',
'firebase/app': 'firebase',
'firebase/messaging': ['firebase', 'messaging'],
'tinode-sdk': 'Tinode',
},
};
}