├── GeekTime-React-Course.pdf ├── README.md ├── demo.png ├── images ├── cow.png ├── elephant.png └── tiger.png ├── package.json ├── public └── index.html └── src ├── Hello.js ├── c01 └── ChatApp.js ├── c02 ├── CommentBox.css ├── CommentBox.js ├── CommentForm.js ├── CommentItem.js ├── CommentList.js ├── StatefulTabSelector.js ├── TabSelector.css └── TabSelector.js ├── c03 └── Clock.js ├── c04 ├── Clock.js ├── SnapshotSample.css └── SnapshotSample.js ├── c05 └── DomDiff.js ├── c06 ├── AdvancedTabSelector.js └── withTimer.js ├── c07 └── LocaleSample.js ├── c11 └── PureRedux.js ├── c12 └── Counter.js ├── c13 ├── AsyncAction.js └── ReduxMiddleware.js ├── c14 └── OrgActions.js ├── c16 └── RouterSample.js ├── c17 ├── NestedRoute.js └── RouterParams.js ├── c29 ├── FormBuilder.js ├── FormSubmit.js └── FormSubmitAntd.js ├── c30 └── DynamicForm.js ├── c31 ├── App.css ├── App.js ├── DetailPage.js ├── ListPage.js ├── actions.js └── reducer.js ├── c33 └── MultipleRequest.js ├── c35 ├── App.js ├── Step1.js ├── Step2.js └── Step3.js ├── c36 ├── Layout1.css ├── Layout1.js ├── Layout2.css ├── Layout2.js ├── LayoutResize.css └── LayoutResize.js ├── c37 ├── AntdDialog.js ├── PortalSample.css └── PortalSample.js ├── c38 ├── D3Sample.css ├── D3Sample.js └── data.json ├── c40 ├── DndSample.css └── DndSample.js ├── c43 └── ReselectSample.js ├── c44 └── Suspense.js ├── index.css ├── index.js └── index.less /GeekTime-React-Course.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supnate/react-geek-time/e9cf2b61c95d75c86f29dc821576e3ccb22b0624/GeekTime-React-Course.pdf -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 极客时间:React 从入门到精通 2 | ### 所有课程已经更新完毕,感谢大家支持!🎉🎉🎉 3 | 4 | 本 Repo 包含了所有课程的演示代码,代码由 codesandbox.io 同步到本 Repo:https://codesandbox.io/s/6n20nrzlxz 5 | 6 | 通过 codesandbox.io 您可以在线修改演示代码尝试运行结果,无需本地部署。 7 | 8 | [课程讲稿下载](https://github.com/supnate/react-geek-time/raw/master/GeekTime-React-Course.pdf) 9 | 10 | # Demo 结构 11 | 如下图,左侧为所有代码,按课程顺序进行 Demo 的组织。右侧为演示界面,菜单显示了所有可运行的 Demo 链接。点击菜单可以看到运行的结果。 12 | 13 | 14 | 15 | # Demo 列表 16 | * 01 chat-app: 简单的 React 组件和交互演示 17 | * 02 comment-box:评论框界面的组件拆分和实现 18 | * 03 clock: JSX 语法演示 19 | * 04 clock: 显示当前时间的组件,演示生命周期方法的调用 20 | * 05 dom-diff:演示 DOM Diff 的算法原理 21 | * 06 adv-tab-selector,withTimer: 高阶组件和函数作为子组件 22 | * 07 locale-sample: 使用 Conext API 实现多语言切换 23 | * 11 pure-reducer:纯 Redux 的使用 24 | * 12 counter:在 React 中使用 Redux 25 | * 13 async-action:Redux 异步 action,中间件的概念 26 | * 14 org-action:如何组织 Redux 的 action 和 reducer 27 | * 16 router-sample:路由不只是页面切换,更是代码组织方式 28 | * 17.1 router-params:路由参数定义 29 | * 17.2 nexted-route:嵌套路由 30 | * 29.1 form-submit: 表单提交 31 | * 29.2 form-submit-antd:使用 antd 的表单组件 32 | * 30 dynamic-form:动态表单 33 | * 31 list-page:列表页的翻页,搜索和缓存 34 | * 33 multiple-request:页面多个请求的处理 35 | * 35 wizard-sample:基于路由实现向导页面 36 | * 36.1 layout1:常用布局的实现 37 | * 36.2 layout2: 常用布局的实现 38 | * 36.3 layout-resize:实现侧边栏可调整宽度 39 | * 37.1 portal-example:使用 React Portals 实现的对话框 40 | * 37.2 antd-dialog:使用 antd 实现对话框 41 | * 40 dnd-sample:在 React 中实现拖放功能 42 | * 43 reselect-sample:使用 reselect 避免重复计算 43 | * 44 suspense:React 的异步渲染 44 | 45 | 46 | # License 47 | MIT 48 | -------------------------------------------------------------------------------- /demo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supnate/react-geek-time/e9cf2b61c95d75c86f29dc821576e3ccb22b0624/demo.png -------------------------------------------------------------------------------- /images/cow.png: -------------------------------------------------------------------------------- 1 | https://uploads.codesandbox.io/uploads/user/91e44e0f-7b6f-4393-ae82-5192a414ab1e/jJAv-cow.png -------------------------------------------------------------------------------- /images/elephant.png: -------------------------------------------------------------------------------- 1 | https://uploads.codesandbox.io/uploads/user/91e44e0f-7b6f-4393-ae82-5192a414ab1e/nHjH-elephant.png -------------------------------------------------------------------------------- /images/tiger.png: -------------------------------------------------------------------------------- 1 | https://uploads.codesandbox.io/uploads/user/91e44e0f-7b6f-4393-ae82-5192a414ab1e/wbwH-tiger.png -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-geek-time", 3 | "version": "1.0.0", 4 | "description": "", 5 | "keywords": [], 6 | "main": "src/index.js", 7 | "dependencies": { 8 | "antd": "3.7.1", 9 | "axios": "0.18.0", 10 | "d3": "5.5.0", 11 | "react": "16.4.1", 12 | "react-dom": "16.4.1", 13 | "react-redux": "5.0.7", 14 | "react-router": "4.3.1", 15 | "react-router-dom": "4.3.1", 16 | "react-scripts": "1.1.4", 17 | "redux": "4.0.0", 18 | "redux-logger": "3.0.6", 19 | "redux-thunk": "2.3.0", 20 | "reselect": "3.0.1", 21 | "simple-cache-provider": "0.7.0" 22 | }, 23 | "devDependencies": {}, 24 | "scripts": { 25 | "start": "react-scripts start", 26 | "build": "react-scripts build", 27 | "test": "react-scripts test --env=jsdom", 28 | "eject": "react-scripts eject" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 14 | 23 | React App 24 | 25 | 26 | 27 | 30 |
31 |
32 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /src/Hello.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | 3 | export default () => ( 4 |
5 |

Welcome to React course!

6 |

Click the left side menu to navigate.

7 |
8 | ); 9 | -------------------------------------------------------------------------------- /src/c01/ChatApp.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import withTimer from "../c06/withTimer"; 3 | 4 | class MessageList extends React.PureComponent { 5 | render() { 6 | return ; 7 | } 8 | } 9 | 10 | export class ChatApp extends React.Component { 11 | state = { 12 | messages: [], 13 | inputMsg: "", 14 | }; 15 | 16 | handleInput = evt => { 17 | this.setState({ 18 | inputMsg: evt.target.value, 19 | }); 20 | }; 21 | handleSend = () => { 22 | const text = this.state.inputMsg; 23 | if (text) { 24 | const newMessages = [...this.state.messages, text]; 25 | this.setState({ 26 | messages: newMessages, 27 | inputMsg: "", 28 | }); 29 | } 30 | }; 31 | render() { 32 | return ( 33 |
34 | 35 |
36 | 37 | 38 |
39 |

{this.props.time.toLocaleString()}

40 |
41 | ); 42 | } 43 | } 44 | 45 | export default withTimer(ChatApp); 46 | -------------------------------------------------------------------------------- /src/c02/CommentBox.css: -------------------------------------------------------------------------------- 1 | .comment-box { 2 | width: 400px; 3 | } 4 | .comment-box h1 { 5 | font-size: 28px; 6 | border-bottom: 1px solid #ddd; 7 | padding-bottom: 20px; 8 | } 9 | 10 | .comment-item { 11 | position: relative; 12 | height: 80px; 13 | padding-left: 80px; 14 | padding-top: 5px; 15 | } 16 | 17 | .comment-item .avatar { 18 | position: absolute; 19 | left: 10px; 20 | top: 0px; 21 | width: 60px; 22 | height: 60px; 23 | background-color: #eee; 24 | } 25 | 26 | .comment-form { 27 | } 28 | 29 | .comment-form textarea { 30 | width: 100%; 31 | margin-top: 10px; 32 | border: 1px solid #ccc; 33 | height: 100px; 34 | margin-bottom: 20px; 35 | } 36 | -------------------------------------------------------------------------------- /src/c02/CommentBox.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import CommentList from "./CommentList"; 3 | import CommentForm from "./CommentForm"; 4 | import withTimer from "../c06/withTimer"; 5 | import "./CommentBox.css"; 6 | 7 | const comments = [ 8 | { 9 | author: "Nate", 10 | content: "Hello React! This is a sample comment.", 11 | }, 12 | { author: "Kevin", content: "Hello Redux!" }, 13 | { author: "Bood", content: "Hello Rekit!" }, 14 | ]; 15 | export class CommentBox extends React.PureComponent { 16 | render() { 17 | return ( 18 |
19 |

Comments ({comments.length})

20 | 21 | 22 | {this.props.time.getTime()} 23 |
24 | ); 25 | } 26 | } 27 | 28 | export default withTimer(CommentBox); 29 | -------------------------------------------------------------------------------- /src/c02/CommentForm.js: -------------------------------------------------------------------------------- 1 | import React, { PureComponent } from "react"; 2 | import PropTypes from "prop-types"; 3 | 4 | export default class CommentForm extends PureComponent { 5 | static propTypes = { 6 | comments: PropTypes.object.isRequired 7 | }; 8 | render() { 9 | return ( 10 |
11 |
evt.preventDefault()}> 12 |