├── .gitignore ├── README.md ├── .babelrc ├── src ├── common │ ├── style │ │ └── main.css │ └── img │ │ ├── 128H.jpg │ │ ├── elyse.png │ │ ├── molly.png │ │ └── matthew.png ├── .DS_Store ├── components │ ├── parc │ │ ├── img │ │ │ ├── jenny.jpg │ │ │ ├── joe.jpg │ │ │ ├── matt.jpg │ │ │ ├── molly.jpg │ │ │ └── elliot.jpg │ │ ├── TimeHeader.js │ │ ├── Props.js │ │ ├── Reply.js │ │ ├── CommentBox.js │ │ ├── Comment.js │ │ └── JSX.js │ ├── home │ │ └── Home.js │ ├── nav │ │ └── Nav.js │ ├── cardWrap │ │ └── CardWrap.js │ └── card │ │ └── Card.js ├── index.html ├── app.js └── p.js ├── .DS_Store ├── dist ├── assets │ ├── 36d50c1381fda7c71d12b6643cbe1ee0.svg │ ├── 046e91f77483a277a434bac9ae4885e2.png │ ├── 1af9777b04f8a459bf3e8f2226237f8b.jpg │ ├── 45fdd64889fe43b886545dce5d85b93d.png │ ├── 674f50d287a8c48dc19ba404d20fe713.eot │ ├── 9c74e172f87984c48ddf5c8108cabe67.png │ ├── b06871f281fee6b241d60582ae9369b9.ttf │ ├── ed66029dc38fd1e1d6e3d0c15761f793.png │ ├── af7ae505a9eed503f8b8e6982036873e.woff2 │ └── fee66e712a8a08eef5805a46892932ad.woff └── in.html ├── ser.js ├── semantic.json ├── server.js ├── package.json └── webpack.config.js /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | semantic -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # React_Lab 2 | React Lab 3 | -------------------------------------------------------------------------------- /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["env","react"] 3 | } 4 | -------------------------------------------------------------------------------- /src/common/style/main.css: -------------------------------------------------------------------------------- 1 | .img{ 2 | width: 500px; 3 | } 4 | -------------------------------------------------------------------------------- /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zouyang1230/React_Lab/HEAD/.DS_Store -------------------------------------------------------------------------------- /src/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zouyang1230/React_Lab/HEAD/src/.DS_Store -------------------------------------------------------------------------------- /src/common/img/128H.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zouyang1230/React_Lab/HEAD/src/common/img/128H.jpg -------------------------------------------------------------------------------- /src/common/img/elyse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zouyang1230/React_Lab/HEAD/src/common/img/elyse.png -------------------------------------------------------------------------------- /src/common/img/molly.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zouyang1230/React_Lab/HEAD/src/common/img/molly.png -------------------------------------------------------------------------------- /src/common/img/matthew.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zouyang1230/React_Lab/HEAD/src/common/img/matthew.png -------------------------------------------------------------------------------- /src/components/parc/img/jenny.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zouyang1230/React_Lab/HEAD/src/components/parc/img/jenny.jpg -------------------------------------------------------------------------------- /src/components/parc/img/joe.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zouyang1230/React_Lab/HEAD/src/components/parc/img/joe.jpg -------------------------------------------------------------------------------- /src/components/parc/img/matt.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zouyang1230/React_Lab/HEAD/src/components/parc/img/matt.jpg -------------------------------------------------------------------------------- /src/components/parc/img/molly.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zouyang1230/React_Lab/HEAD/src/components/parc/img/molly.jpg -------------------------------------------------------------------------------- /src/components/parc/img/elliot.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zouyang1230/React_Lab/HEAD/src/components/parc/img/elliot.jpg -------------------------------------------------------------------------------- /dist/assets/36d50c1381fda7c71d12b6643cbe1ee0.svg: -------------------------------------------------------------------------------- 1 | module.exports = __webpack_public_path__ + "912ec66d7572ff821749319396470bde.svg"; -------------------------------------------------------------------------------- /dist/assets/046e91f77483a277a434bac9ae4885e2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zouyang1230/React_Lab/HEAD/dist/assets/046e91f77483a277a434bac9ae4885e2.png -------------------------------------------------------------------------------- /dist/assets/1af9777b04f8a459bf3e8f2226237f8b.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zouyang1230/React_Lab/HEAD/dist/assets/1af9777b04f8a459bf3e8f2226237f8b.jpg -------------------------------------------------------------------------------- /dist/assets/45fdd64889fe43b886545dce5d85b93d.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zouyang1230/React_Lab/HEAD/dist/assets/45fdd64889fe43b886545dce5d85b93d.png -------------------------------------------------------------------------------- /dist/assets/674f50d287a8c48dc19ba404d20fe713.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zouyang1230/React_Lab/HEAD/dist/assets/674f50d287a8c48dc19ba404d20fe713.eot -------------------------------------------------------------------------------- /dist/assets/9c74e172f87984c48ddf5c8108cabe67.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zouyang1230/React_Lab/HEAD/dist/assets/9c74e172f87984c48ddf5c8108cabe67.png -------------------------------------------------------------------------------- /dist/assets/b06871f281fee6b241d60582ae9369b9.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zouyang1230/React_Lab/HEAD/dist/assets/b06871f281fee6b241d60582ae9369b9.ttf -------------------------------------------------------------------------------- /dist/assets/ed66029dc38fd1e1d6e3d0c15761f793.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zouyang1230/React_Lab/HEAD/dist/assets/ed66029dc38fd1e1d6e3d0c15761f793.png -------------------------------------------------------------------------------- /dist/assets/af7ae505a9eed503f8b8e6982036873e.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zouyang1230/React_Lab/HEAD/dist/assets/af7ae505a9eed503f8b8e6982036873e.woff2 -------------------------------------------------------------------------------- /dist/assets/fee66e712a8a08eef5805a46892932ad.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zouyang1230/React_Lab/HEAD/dist/assets/fee66e712a8a08eef5805a46892932ad.woff -------------------------------------------------------------------------------- /src/components/parc/TimeHeader.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | export default function TimeHeader({date}){ 4 | 5 | return ( 6 |

7 | {date} 8 |

9 | ); 10 | } 11 | 12 | TimeHeader.defaultProps = { 13 | date: '今天' 14 | } 15 | -------------------------------------------------------------------------------- /src/components/parc/Props.js: -------------------------------------------------------------------------------- 1 | 2 | import CommentBox from './CommentBox'; 3 | 4 | 5 | 6 | export default class Props extends Component{ 7 | constructor(props){ 8 | super(props); 9 | } 10 | 11 | render(){ 12 | 13 | let {data} = this.props; 14 | 15 | return ( 16 | 17 | 18 | 19 | ); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/components/home/Home.js: -------------------------------------------------------------------------------- 1 | import React, {Component} from 'react'; 2 | 3 | export default class Home extends Component{ 4 | render(){ 5 | console.log('home'); 6 | return ( 7 | 12 | ) 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 9 | 10 |
11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /dist/in.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 9 | 10 |
11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /ser.js: -------------------------------------------------------------------------------- 1 | const webpack = require('webpack'); 2 | const WebpackDevServer = require('webpack-dev-server'); 3 | const config = require('./webpack.config'); 4 | 5 | const compiler = webpack(config); 6 | 7 | let port = 9000; 8 | 9 | config.entry.unshift( 10 | `webpack-dev-server/client?http://localhost:${port}`, 11 | 'webpack/hot/dev-server' 12 | ) 13 | 14 | new WebpackDevServer(compiler, { 15 | hot: true, 16 | contentBase: './src/', 17 | publicPath: '/assets/' 18 | }) 19 | .listen(port) 20 | -------------------------------------------------------------------------------- /semantic.json: -------------------------------------------------------------------------------- 1 | { 2 | "base": "semantic\\", 3 | "paths": { 4 | "source": { 5 | "config": "src/theme.config", 6 | "definitions": "src/definitions/", 7 | "site": "src/site/", 8 | "themes": "src/themes/" 9 | }, 10 | "output": { 11 | "packaged": "dist/", 12 | "uncompressed": "dist/components/", 13 | "compressed": "dist/components/", 14 | "themes": "dist/themes/" 15 | }, 16 | "clean": "dist/" 17 | }, 18 | "permission": false, 19 | "autoInstall": false, 20 | "rtl": false, 21 | "version": "2.2.10" 22 | } -------------------------------------------------------------------------------- /server.js: -------------------------------------------------------------------------------- 1 | const webpack = require('webpack'); 2 | const path = require('path'); 3 | const webpackDevMiddleware = require('webpack-dev-middleware'); 4 | const webpackHotMiddleware = require('webpack-hot-middleware'); 5 | const config = require('./webpack.config'); 6 | 7 | const bs = require('browser-sync').create(); 8 | 9 | config.entry.unshift('webpack-hot-middleware/client?reload=true') 10 | 11 | let app = new (require('express'))(); 12 | 13 | let port = 7000; 14 | 15 | let compiler = webpack(config); 16 | 17 | app.use( webpackDevMiddleware(compiler, {publicPath: '/assets/'}) ); 18 | 19 | app.use( webpackHotMiddleware(compiler) ); 20 | 21 | app.get('/', (req, res)=> res.sendFile(path.resolve(__dirname, 'src/index.html') ) ) 22 | 23 | app.listen(port); 24 | -------------------------------------------------------------------------------- /src/components/nav/Nav.js: -------------------------------------------------------------------------------- 1 | import React, {Component} from 'react'; 2 | 3 | export default class Nav extends Component{ 4 | render(){ 5 | console.log('nav'); 6 | let {changeView} = this.props; 7 | 8 | return ( 9 |
10 |
Noods
11 |
{changeView('home')}} 14 | >Home
15 |
{changeView('list')}} 18 | >List
19 |
Login
20 |
21 | ) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/components/cardWrap/CardWrap.js: -------------------------------------------------------------------------------- 1 | import React, {Component} from 'react'; 2 | import Card from 'card/Card.js'; 3 | 4 | 5 | export default class CardWrap extends Component{ 6 | 7 | componentDidUpdate(){ 8 | console.log('CardWrap 更新好了'); 9 | } 10 | 11 | componentDidMount(){ 12 | console.log('CardWrap 渲染完成'); 13 | } 14 | 15 | componentWillUnmount(){ 16 | console.log('CardWrap 被卸载了'); 17 | } 18 | 19 | render(){ 20 | 21 | console.log('cardWrap'); 22 | 23 | let { data } = this.props; 24 | 25 | let cards = data.map((elt, i)=>{ 26 | return ( 27 | 28 | ) 29 | }); 30 | 31 | return ( 32 |
33 | {cards} 34 |
35 | ) 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react_demos", 3 | "version": "1.0.0", 4 | "description": "React demos", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "dev": "webpack", 9 | "start": "node server", 10 | "ser": "node ser" 11 | }, 12 | "author": "zouyang", 13 | "license": "ISC", 14 | "dependencies": { 15 | "prop-types": "^15.5.8", 16 | "react": "^15.5.0", 17 | "react-dom": "^15.5.0", 18 | "semantic-ui": "^2.2.10" 19 | }, 20 | "devDependencies": { 21 | "babel-core": "^6.24.0", 22 | "babel-loader": "^6.4.1", 23 | "babel-preset-env": "^1.3.2", 24 | "babel-preset-react": "^6.23.0", 25 | "browser-sync": "^2.18.8", 26 | "css-loader": "^0.28.0", 27 | "express": "^4.15.2", 28 | "file-loader": "^0.11.1", 29 | "html-webpack-plugin": "^2.28.0", 30 | "react-hot-loader": "^1.3.1", 31 | "style-loader": "^0.16.1", 32 | "url-loader": "^0.5.8", 33 | "webpack": "^2.3.3", 34 | "webpack-dev-middleware": "^1.10.1", 35 | "webpack-dev-server": "^2.4.2", 36 | "webpack-hot-middleware": "^2.18.0" 37 | }, 38 | "repository": { 39 | "type": "git", 40 | "url": "git+https://github.com/zouyang1230/React_demos.git" 41 | }, 42 | "bugs": { 43 | "url": "https://github.com/zouyang1230/React_demos/issues" 44 | }, 45 | "homepage": "https://github.com/zouyang1230/React_demos#readme" 46 | } 47 | -------------------------------------------------------------------------------- /src/components/parc/Reply.js: -------------------------------------------------------------------------------- 1 | 2 | let avatar = require('parc/img/molly.jpg'); 3 | 4 | export default class Reply extends Component{ 5 | constructor(props){ 6 | super(props); 7 | 8 | this.onSubmit = this.onSubmit.bind(this); 9 | } 10 | 11 | onSubmit(ev){ 12 | ev.stopPropagation(); 13 | ev.preventDefault(); 14 | 15 | let {comment} = this.props; 16 | 17 | 18 | if(!comment.subComment){ 19 | comment.subComment = []; 20 | } 21 | 22 | comment.subComment.push({ 23 | time: '00:00', 24 | avatar: avatar, 25 | name: this.refs.ipt.value, 26 | content: this.refs.area.value 27 | }); 28 | this.props.replySomeone(); 29 | } 30 | 31 | render(){ 32 | return ( 33 |
36 |
37 | 38 |
39 |
40 | 44 |
45 | 48 |
49 | ); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/components/parc/CommentBox.js: -------------------------------------------------------------------------------- 1 | 2 | import Reply from './Reply'; 3 | import TimeHeader from './TimeHeader'; 4 | import Comment from './Comment'; 5 | 6 | export default class CommentBox extends Component{ 7 | constructor(props){ 8 | super(props); 9 | this.state = { 10 | data: props.data, 11 | someReplyIn: null 12 | } 13 | 14 | this.replySomeone = this.replySomeone.bind(this); 15 | this.replyInFix = this.replyInFix.bind(this); 16 | } 17 | 18 | replySomeone(){ 19 | this.setState({someReplyIn: null}); 20 | } 21 | 22 | replyInFix(someReplyIn){ 23 | this.setState({someReplyIn}); 24 | } 25 | 26 | render(){ 27 | let {data, someReplyIn} = this.state; 28 | 29 | let {replySomeone, replyInFix} = this; 30 | 31 | let array = []; 32 | let lastDate = null; 33 | 34 | data.forEach((comment, i)=>{ 35 | 36 | let {date, time, name, content, avatar, subComment} = comment; 37 | 38 | if(lastDate !== date){ 39 | array.push(); 40 | } 41 | array.push( 42 | 46 | ); 47 | lastDate = date; 48 | }); 49 | 50 | return ( 51 |
52 |
53 |
54 |

Comments

55 | {array} 56 |
57 |
58 |
59 | ); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /webpack.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const webpack = require('webpack'); 3 | const HtmlWebpackPlugin = require('html-webpack-plugin'); 4 | module.exports = { 5 | entry: [ 6 | './src/app.js' 7 | ], 8 | 9 | output: { 10 | filename: 'main.js', 11 | path: path.resolve(__dirname, 'dist/assets'), 12 | publicPath: '/assets/' 13 | }, 14 | 15 | module: { 16 | rules: [ 17 | { 18 | test: /\.js$/, 19 | use: ['babel-loader'], 20 | include:[ 21 | path.resolve(__dirname, './src') 22 | ] 23 | }, 24 | { 25 | test: /\.css$/, 26 | use: ['style-loader','css-loader'] 27 | }, 28 | { 29 | test: /\.(png|jpg|jpeg|gif)$/, 30 | use: ['url-loader?limit=8192'], 31 | }, 32 | { 33 | test: /\.(mp4|ogg|svg)$/, 34 | use: ['file-loader'] 35 | }, 36 | { 37 | test: /\.(woff|woff2)(\?v=\d+\.\d+\.\d+)?$/, 38 | use: ['url-loader?limit=10000&mimetype=application/font-woff'] 39 | }, 40 | { 41 | test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, 42 | use: ['url-loader?limit=10000&mimetype=application/octet-stream'] 43 | }, 44 | { 45 | test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, 46 | use: ['file-loader'] 47 | }, 48 | { 49 | test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, 50 | use: ['url-loader?limit=10000&mimetype=image/svg+xml'] 51 | } 52 | ] 53 | }, 54 | 55 | resolve: { 56 | modules: [ 57 | 'node_modules', 58 | path.resolve(__dirname, 'src/common'), 59 | path.resolve(__dirname, 'src/components') 60 | ] 61 | }, 62 | 63 | 64 | plugins: [ 65 | new webpack.HotModuleReplacementPlugin(), 66 | new HtmlWebpackPlugin({ 67 | filename: '../in.html', //index.html 68 | template: './src/index.html' 69 | }), 70 | new webpack.ProvidePlugin({ 71 | React: 'react', 72 | ReactDOM: 'react-dom', 73 | Component: ['react', 'Component'], 74 | PT: 'prop-types' 75 | }) 76 | ], 77 | 78 | devtool: 'eval-source-map' 79 | 80 | 81 | } 82 | -------------------------------------------------------------------------------- /src/components/parc/Comment.js: -------------------------------------------------------------------------------- 1 | 2 | let propTypes = { 3 | name: PT.oneOf([ 'Mike', 'Matt','Sal', 'Hurley', 'Molly', 'Jenny', 'Elliot', 'Ben', 'Jane']) 4 | } 5 | 6 | export default class Comment extends Component{ 7 | constructor(props){ 8 | super(props); 9 | 10 | this.state = { 11 | inReply: false 12 | } 13 | } 14 | 15 | render(){ 16 | let {time, name, content, avatar, subComment, replySomeone, Reply, comment, replyInFix, someReplyIn} = this.props; 17 | 18 | // let {inReply} = this.state; 19 | let inReply = (someReplyIn === comment); 20 | return ( 21 |
22 | 23 | 24 | 25 |
26 | {name} 27 |
28 | {time} 29 |
30 |
31 | {content} 32 |
33 | 44 | {inReply ? ( 45 | 46 | ) : null } 47 | { 48 | subComment ? ( 49 | subComment.map((elt, i)=>{ 50 | return (); 51 | }) 52 | ) : (null) 53 | } 54 |
55 |
56 | ); 57 | } 58 | } 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | Comment.defaultProps = { 94 | name: 'Janeg' 95 | } 96 | 97 | 98 | Comment.propTypes = propTypes; 99 | -------------------------------------------------------------------------------- /src/components/card/Card.js: -------------------------------------------------------------------------------- 1 | import React, {Component} from 'react'; 2 | import PropTypes from 'prop-types'; 3 | 4 | 5 | let propTypes = { 6 | imgSrc: PropTypes.string, 7 | name: PropTypes.string.isRequired, 8 | meta: PropTypes.string, 9 | desc: PropTypes.string, 10 | joined: PropTypes.number, 11 | likeNum: PropTypes.number 12 | } 13 | 14 | let contextTypes = { 15 | et: PropTypes.string 16 | } 17 | 18 | export default class Card extends Component{ 19 | 20 | constructor(props){ 21 | super(props); 22 | this.state = { 23 | isHeartON: false, 24 | year: props.joined 25 | }; 26 | 27 | this.heartClick = this.heartClick.bind(this); 28 | this.yearAdd = this.yearAdd.bind(this); 29 | } 30 | 31 | yearAdd(){ 32 | 33 | let {year} = this.state 34 | 35 | this.setState({ 36 | year: year + 10 37 | }); 38 | } 39 | 40 | heartClick(event){ 41 | let {isHeartON} = this.state; 42 | isHeartON = !isHeartON; 43 | 44 | console.log(event.target); 45 | 46 | this.setState({ 47 | isHeartON 48 | }) 49 | } 50 | 51 | render(){ 52 | let {imgSrc, name, meat, desc, joined, likeNum} = this.props; 53 | 54 | let {et} = this.context; 55 | 56 | let {isHeartON, year} = this.state; 57 | 58 | let heartClass = isHeartON ? '' : 'empty'; 59 | 60 | return ( 61 |
62 |
63 | 64 |
65 |
66 |
{name}
67 |
68 | {meat} 69 |
70 |
{desc}
71 |
72 |
73 | {`${et} in ${year}`} 77 | 78 | {`${likeNum} Like`} 82 | 83 |
84 |
85 | ) 86 | } 87 | } 88 | 89 | Card.propTypes = propTypes; 90 | Card.contextTypes = contextTypes; 91 | -------------------------------------------------------------------------------- /src/app.js: -------------------------------------------------------------------------------- 1 | import React, {Component} from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import PropTypes from 'prop-types'; 4 | 5 | import Nav from 'nav/Nav.js'; 6 | import CardWrap from 'cardWrap/CardWrap.js'; 7 | import Home from 'home/Home.js'; 8 | 9 | require('../semantic/dist/semantic.css'); 10 | require('./common/style/main.css'); 11 | 12 | let data = [ 13 | { 14 | imgSrc: require('img/matthew.png'), 15 | name: 'Matt', 16 | meta: 'Friends', 17 | desc: 'Matthew is an interior designer living in New York.', 18 | joined: 2013, 19 | likeNum: 75 20 | }, 21 | { 22 | imgSrc: require('img/molly.png'), 23 | name: 'Molly', 24 | meta: 'Coworker', 25 | desc: 'Molly is a personal assistant living in Paris.', 26 | joined: 2013, 27 | likeNum: 35 28 | }, 29 | { 30 | imgSrc: require('img/elyse.png'), 31 | name: 'Elyse', 32 | meta: 'Coworker', 33 | desc: 'Elyse is a copywriter working in New York.', 34 | joined: 2014, 35 | likeNum: 151 36 | } 37 | ]; 38 | 39 | class App extends Component{ 40 | 41 | constructor(props){ 42 | super(props); 43 | this.state = { 44 | view: 'home' 45 | } 46 | this.changeView = this.changeView.bind(this); 47 | } 48 | 49 | changeView(view){ 50 | this.setState({ 51 | view 52 | }) 53 | } 54 | 55 | getChildContext(){ 56 | return { 57 | et: 'Died' 58 | } 59 | } 60 | 61 | componentDidUpdate(){ 62 | console.log('App 更新好了'); 63 | } 64 | 65 | componentDidMount(){ 66 | console.log('APP 渲染完成'); 67 | } 68 | 69 | render(){ 70 | console.log('app'); 71 | let {view} = this.state; 72 | 73 | let {data} = this.props; 74 | 75 | let viewComp = null; 76 | 77 | switch (view) { 78 | 79 | case 'list': 80 | viewComp = 81 | break; 82 | case 'home': 83 | viewComp = 84 | default: 85 | 86 | } 87 | 88 | return ( 89 |
90 |
91 |
94 | ); 95 | } 96 | } 97 | 98 | App.childContextTypes = { 99 | et: PropTypes.string 100 | } 101 | 102 | 103 | ReactDOM.render( 104 | , 105 | document.getElementById('root') 106 | ); 107 | 108 | 109 | 110 | if(module.hot){  111 | module.hot.accept() 112 | } 113 | -------------------------------------------------------------------------------- /src/p.js: -------------------------------------------------------------------------------- 1 | 2 | import JSX from 'parc/JSX'; 3 | import Props from 'parc/Props'; 4 | 5 | require('../semantic/dist/semantic.css'); 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | let data = [ 19 | {date: '今天', time: '11:20', name: 'Matt', content: '你好', avatar: require("parc/img/matt.jpg")}, 20 | { 21 | date: '今天', time: '11:20', name: 'Jenny', content: '你好', avatar: require("parc/img/molly.jpg"), 22 | subComment: [ 23 | { time: '11:20',name: 'Sal', content: '你好', avatar: require("parc/img/molly.jpg")}, 24 | { time: '11:20',name: 'Jenny', content: '你好', avatar: require("parc/img/jenny.jpg")}, 25 | { time: '11:20',name: 'Elliot', content: '你好', avatar: require("parc/img/elliot.jpg")}, 26 | { time: '11:20',name: 'Molly', content: '你好', avatar: require("parc/img/molly.jpg")} 27 | ] 28 | }, 29 | {date: '今天', time: '11:20', name: 'Molly', content: '你好', avatar: require("parc/img/molly.jpg")}, 30 | {date: '今天', time: '11:20', name: 'Elliot', content: '你好', avatar: require("parc/img/matt.jpg")}, 31 | {date: '昨天', time: '11:20', name: 'Sal', content: '你好', avatar: require("parc/img/molly.jpg")}, 32 | {date: '昨天', time: '11:20', name: 'Mike', content: '你好', avatar: require("parc/img/matt.jpg")}, 33 | {date: '前天', time: '11:20', name: 'Sal', content: '你好', avatar: require("parc/img/molly.jpg")}, 34 | { 35 | date: '前天', time: '11:20', name: 'Hurley', content: '你好', avatar: require("parc/img/matt.jpg"), 36 | subComment: [ 37 | { 38 | time: '11:20',name: 'Sal', content: '你好', avatar: require("parc/img/molly.jpg"), 39 | subComment: [ 40 | { 41 | time: '11:20',name: 'Sal', content: '你好', avatar: require("parc/img/molly.jpg"), 42 | subComment: [ 43 | { time: '11:20',name: 'Molly', content: '你好', avatar: require("parc/img/molly.jpg")} 44 | ] 45 | }, 46 | { time: '11:20',name: 'Jenny', content: '你好', avatar: require("parc/img/jenny.jpg")}, 47 | { time: '11:20',name: 'Elliot', content: '你好', avatar: require("parc/img/elliot.jpg")}, 48 | { time: '11:20',name: 'Molly', content: '你好', avatar: require("parc/img/molly.jpg")} 49 | ] 50 | } 51 | ] 52 | }, 53 | {date: '前天', time: '11:20', name: 'Ben', content: '你好', avatar: require("parc/img/matt.jpg")}, 54 | {date: '前天', time: '11:20', name: 'Jane', content: '你好', avatar: require("parc/img/molly.jpg")} 55 | ]; 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | class III extends Component{ 85 | constructor(props){ 86 | super(props); 87 | 88 | this.state = { 89 | val: '' 90 | } 91 | 92 | } 93 | 94 | render(){ 95 | 96 | let arr = Array.from({length:1000}).map((elt, i)=>{ 97 | return ( 98 | { 101 | this.setState({val: ev.target.value}) 102 | }} 103 | /> 104 | ) 105 | }); 106 | 107 | return ( 108 |
109 | { 110 | arr 111 | } 112 |
113 | 114 | ); 115 | } 116 | } 117 | 118 | ReactDOM.render( 119 | , 120 | document.getElementById('root') 121 | ); 122 | 123 | 124 | 125 | if(module.hot){  126 | module.hot.accept() 127 | } 128 | -------------------------------------------------------------------------------- /src/components/parc/JSX.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | export default class JSX extends Component{ 4 | constructor(props){ 5 | super(props); 6 | } 7 | 8 | render(){ 9 | return ( 10 | 11 |
12 |
13 |
14 |

Comments

15 |
16 | 17 | 18 | 19 |
20 | Matt 21 | {/*
22 | Today at 5:42PM 23 |
*/} 24 |
25 | How artistic! 26 |
27 |
28 | 回复 29 |
30 |
31 |
32 |
33 | 34 | 35 | 36 |
37 | Elliot Fu 38 | {/*
39 | Yesterday at 12:30AM 40 |
*/} 41 |
42 |

This has been very useful for my research. Thanks as well!

43 |
44 |
45 | 回复 46 |
47 |
48 |
49 |
50 | 51 | 52 | 53 |
54 | Jenny Hess 55 | {/*
56 | Just now 57 |
*/} 58 |
59 | Elliot you are always so right :) 60 |
61 |
62 | 回复 63 |
64 |
65 |
66 |
67 |
68 |
69 | 70 | 71 | 72 |
73 | Joe Henderson 74 | {/*
75 | 5 days ago 76 |
*/} 77 |
78 | Dude, this is awesome. Thanks so much 79 |
80 |
81 | 回复 82 |
83 |
84 |
85 |
86 |
87 | 90 |
91 | 94 |
95 |
96 |
97 |
98 | ); 99 | } 100 | } 101 | --------------------------------------------------------------------------------