This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 文/guog(簡書作者) | |
| 原文鏈接:http://www.jianshu.com/p/95a269951a1b# | |
| 著作權歸作者所有,轉載請聯繫作者獲得授權,並標註“簡書作者”。 | |
| robocopy empty_dir will_delete_dir /purge |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const counter = (state = 0, action) => { | |
| switch (action.type) { | |
| case 'INCREMENT': | |
| return state + 1; | |
| case 'DECREMENT': | |
| return state - 1; | |
| default: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const counter = (state = 0, action) => { | |
| switch (action.type) { | |
| case 'INCREMENT': | |
| return state + 1; | |
| case 'DECREMENT': | |
| return state - 1; | |
| default: | |
| return state; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const counter = (state = 0, action) => { | |
| switch (action.type) { | |
| case 'INCREMENT': | |
| return state + 1; | |
| case 'DECREMENT': | |
| return state - 1; | |
| default: | |
| return state; | |
| } | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const counter = (state = 0, action) => { | |
| switch (action.type) { | |
| case 'INCREMENT': | |
| return state + 1; | |
| case 'DECREMENT': | |
| return state - 1; | |
| default: | |
| return state; | |
| } | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const addCounter = (list) => { | |
| return [...list,0] | |
| }; | |
| const removeCounter = (list, index) => { | |
| return [ | |
| ...list.slice(0, index), | |
| ...list.slice(index + 1) | |
| ]; | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const toggleTodo = (todo) => { | |
| return { | |
| ...todo, | |
| completed: !todo.completed | |
| } | |
| }; | |
| const testToggleTodo =()=> { | |
| const todoBefore = { | |
| id: 0, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const todos = (state=[], action) => { | |
| switch (action.type) { | |
| case 'ADD_TODO': | |
| return [ | |
| ...state, | |
| { | |
| id: action.id, | |
| text: action.text, | |
| completed: false | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const todos = (state=[], action) => { | |
| switch (action.type) { | |
| case 'ADD_TODO': | |
| return [ | |
| ...state, | |
| { | |
| id: action.id, | |
| text: action.text, | |
| completed: false | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const todo = (state, action) => { | |
| switch (action.type) { | |
| case 'ADD_TODO': | |
| return { | |
| id: action.id, | |
| text: action.text, | |
| completed: false | |
| }; | |
| case 'TOGGLE_TODO': |