# react-webpack-ES6-demo **Repository Path**: mirrors_Binaryify/react-webpack-ES6-demo ## Basic Information - **Project Name**: react-webpack-ES6-demo - **Description**: react-webpack-ES6-demo - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-10-22 - **Last Updated**: 2026-01-11 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README This is a demo for webpack-react demo using ES6; #Features * Equip with React 0.14, ES6 & Babel 6 * Lint with ESlint and Airbnb's .eslintrc * Build with Webpack * Support hot module replacement * Auto Open a new browser tab when Webpack loads, and reload the page when you modified the code * Support git pre-commit hook used to lint and test your code   #start ``` $ git clone git@github.com:zhuangtongfa/react-webpack-ES6-demo.git $ npm install $ npm start ``` You should see a new browser tap opening and a demo in http://127.0.0.1:8080. # main.jsx ```js import React from 'react'; import ReactDOM from 'react-dom' import CommentBox from './component.jsx'; import $ from 'jquery' var commentBox = ReactDOM.render( < CommentBox url = "comments.json" / > , $('#app').get(0)); console.log(commentBox.state.comments) setTimeout(()=>{ commentBox.setState({ comments:[] }) },1000) ``` # component.jsx ```js import React from 'react'; import $ from 'jquery' import './app.scss'; var style={ background:"#eee", padding:"20px" } class CommentForm extends React.Component{ handleSubmit(ev){ ev.preventDefault(); console.log(this.refs.author.value.trim()) //trim 去除两边空格 const author=this.refs.author.value.trim() const comment=this.refs.comment.value.trim() this.props.onSubmit({author:author,comment:comment}) } render(){ return(
) } } class CommentFormB extends React.Component{ constructor(){ super() this.state={ value:"" } } handleInput(ev){ this.setState({ value:ev.target.value }) } render(){ var value=this.state.value; return( ) } } class List extends React.Component { constructor (props) { super(props); this.state={ liked:true } } doSomething(ev){ console.log(ev) this.setState({ liked:!this.state.liked }) } render () { var commentlist = this.props.comments.map(function(item,index) { return