log masuk.js kod
import React from 'react';
import ReactDOM from 'react-dom';
function tick() {
const element = (
<p>
<h1>Hello, world!</h1>
<h2>It is {new Date().toLocaleTimeString()}.</h2>
</p>
);
ReactDOM.render(
element,
document.getElementById('root')
);
}
kod webpack.config.js
const webpack = require('webpack');
const path=require('path');
module.exports=(env)=>{
return {
entry:{
main:'./login.js',
vendor1:'React',
vendor2:'ReactDOM'
},
output:{
filename:'[name].bundle.js',
path:path.resolve(__dirname,'dist')
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
loader: 'babel-loader'
}
]
},
plugins:[
new webpack.optimize.CommonsChunkPlugin({
name:'manifest'
}),
/* new webpack.optimize.CommonsChunkPlugin({
name:'vendor1',
minChunks:(module)=>{
return module.context&&module.context.indexOf('node_modules')!==-1;
}
}),
new webpack.optimize.CommonsChunkPlugin({
name:'vendor2',
minChunks:(module)=>{
return module.context&&module.context.indexOf('node_modules')!==-1;
}
})*/
]
}
}
setInterval(tick, 1000);
Ralat Konsol
WARNING in D:/node/likeread/~/React/lib/ReactPropTypesSecret.js
There are multiple modules with names that only differ in casing.
This can lead to unexpected behavior when compiling on a filesystem with other case-semantic.
Use equal casing. Compare these module identifiers:
* D:\node\likeread\node_modules\babel-loader\lib\index.js!D:\node\likeread\node_modules\React\lib\ReactPropTypesSecret.js
Used by 1 module(s), i. e.
D:\node\likeread\node_modules\babel-loader\lib\index.js!D:\node\likeread\node_modules\React\lib\checkReactTypeSpec.js
* D:\node\likeread\node_modules\babel-loader\lib\index.js!D:\node\likeread\node_modules\react\lib\ReactPropTypesSecret.js
Used by 1 module(s), i. e.
D:\node\likeread\node_modules\babel-loader\lib\index.js!D:\node\likeread\node_modules\react\lib\checkReactTypeSpec.js
ERROR in Entry module not found: Error: Can't resolve 'ReactDOM' in 'D:\node\likeread\public\javascripts'
Apakah yang anda maksudkan dengan
ReactDOM.render()
写在tick
kaedah?