데이터 흐름
{ type: 'LIKE_ARTICLE', articleId: 42 }; { type: 'FETCH_USER_SUCCESS', response: { id: 3, name: 'Megan' } }; { type: 'ADD_TODO', text: 'Read the Redux docs.'};// 애플리케이션의 현재 상태(할일 목록과 선택된 필터) let previousState = { visibleTodoFilter: 'SHOW_ALL', todos: [{ text: 'Read the docs.', complete: false }] }; // 실행되는 액션(할일 추가) let action = { type: 'ADD_TODO', text: 'Understand the flow.' }; // 리듀서가 다음 상태를 반환함 let nextState = todoApp(previousState, action);function todos(state = [], action) { // Somehow calculate it... return nextState; } function visibleTodoFilter(state = 'SHOW_ALL', action) { // Somehow calculate it... return nextState; } let todoApp = combineReducers({ todos, visibleTodoFilter });let nextTodos = todos(state.todos, action); let nextVisibleTodoFilter = visibleTodoFilter(state.visibleTodoFilter, action);return { todos: nextTodos, visibleTodoFilter: nextVisibleTodoFilter };
다음 단계
숙련된 사용자들을 위한 한마디
Last updated