随笔分类 -  Redux

摘要:We will learn how to use store.subscribe() to efficiently persist some of the app’s state to localStorage and restore it after a refresh. To save data 阅读全文
posted @ 2016-06-04 03:43 Zhentiw 阅读(405) 评论(0) 推荐(0) 编辑
摘要:We will learn how to start a Redux app with a previously persisted state, and how it merges with the initial state specified by the reducers. The init 阅读全文
posted @ 2016-06-03 02:22 Zhentiw 阅读(253) 评论(0) 推荐(0) 编辑
摘要:We will create an anction creator to manage the dispatch actions, to keep code maintainable and self-documenting by extracting action creators from th 阅读全文
posted @ 2016-02-12 03:32 Zhentiw 编辑
摘要:Code to be refactored: class FilterLink extends Component { componentDidMount() { const { store } = this.context; this.unsubscribe = store.subscribe(( 阅读全文
posted @ 2016-02-12 03:15 Zhentiw 编辑
摘要:Code to be refacted: const AddTodo = (props, { store }) => { let input; return ( <div> <input ref={node => { input = node; }} /> <button onClick={() = 阅读全文
posted @ 2016-02-12 02:43 Zhentiw 编辑
摘要:Learn how to use the that comes with React Redux instead of the hand-rolled implementation from the previous lesson. Code to be refactored: class Visi 阅读全文
posted @ 2016-02-09 03:17 Zhentiw 编辑
摘要:Previously, we wrote the Provider component by ourself: class Provider extends Component { getChildContext() { return { store: this.props.store }; } r 阅读全文
posted @ 2016-02-08 03:18 Zhentiw 编辑
摘要:We have to write a lot of boiler plate code to pass this chore down as a prop. But there is another way, using the advanced React feature called conte 阅读全文
posted @ 2016-02-05 22:27 Zhentiw 编辑
摘要:n the previous lessons, we used this tool to up level variable to refer to the Redux chore. The components that access this chore, such as the contain 阅读全文
posted @ 2016-02-05 19:17 Zhentiw 编辑
摘要:Clean TodoApp Component, it doesn't need to receive any props from the top level component: const TodoApp = () => ( <div> <AddTodo /> <VisibleTodoList 阅读全文
posted @ 2016-02-04 16:14 Zhentiw 编辑
摘要:Code to be refactored: const AddTodo = ({ onAddClick }) => { let input; return ( <div> <input ref={node => { input = node; }} /> <button onClick={() = 阅读全文
posted @ 2016-02-04 16:00 Zhentiw 编辑
摘要:Code to be refacted: const TodoList = ({ todos, onTodoClick }) => ( <ul> {todos.map(todo => <Todo key={todo.id} {...todo} onClick={() => onTodoClick(t 阅读全文
posted @ 2016-02-04 15:39 Zhentiw 编辑
摘要:Learn how to avoid the boilerplate of passing the props down the intermediate components by introducing more container components. Code to be refactor 阅读全文
posted @ 2016-01-29 16:56 Zhentiw 编辑
摘要:Finally, I just noticed that the to-do app component doesn't actually have to be a class. I can turn it into a function. I prefer to-do that when poss 阅读全文
posted @ 2016-01-27 20:18 Zhentiw 编辑
摘要:Code to be refactored: let nextTodoId = 0; class TodoApp extends Component { render() { const { todos, visibilityFilter } = this.props; const visibleT 阅读全文
posted @ 2016-01-27 20:10 Zhentiw 编辑
摘要:Code to be refactored: let nextTodoId = 0; class TodoApp extends Component { render() { const { todos, visibilityFilter } = this.props; const visibleT 阅读全文
posted @ 2016-01-27 19:09 Zhentiw 编辑
摘要:The code to be refactored: let nextTodoId = 0; class TodoApp extends Component { render() { const { todos, visibilityFilter } = this.props; const visi 阅读全文
posted @ 2016-01-27 18:22 Zhentiw 编辑
摘要:/** * A reducer for a single todo * @param state * @param action * @returns {*} */const todo = ( state, action ) => { switch ( action.type ) { ... 阅读全文
posted @ 2016-01-15 16:48 Zhentiw 编辑
摘要:/** * A reducer for a single todo * @param state * @param action * @returns {*} */const todo = ( state, action ) => { switch ( action.type ) { ... 阅读全文
posted @ 2016-01-12 19:49 Zhentiw 编辑
摘要:Learn how to create a React todo list application using the reducers we wrote before./** * A reducer for a single todo * @param state * @param action ... 阅读全文
posted @ 2016-01-12 18:11 Zhentiw 编辑

点击右上角即可分享
微信分享提示