한번 TodoContainer에서 useActions를 불러와 사용해 봅시다.

    containers/TodoContainer.js

    import React from 'react';
    import { useSelector } from 'react-redux';
    import { changeInput, insert, toggle, remove } from '../modules/todos';
    import Todos from '../components/Todos';
    import useActions from '../lib/useActions';
    
    const TodosContainer = () => {
      const { input, todos } = useSelector(({ todos }) => ({
        input: todos.input,
        todos: todos.todos
      }));
    
      const [onChangeInput, onInsert, onToggle, onRemove] = useActions(
        [changeInput, insert, toggle, remove],
        []
      );
      return (
        <Todos
          input={input}
          todos={todos}
          onChangeInput={onChangeInput}
          onInsert={onInsert}
          onToggle={onToggle}
          onRemove={onRemove}
        />
      );
    };
    
    export default TodosContainer;

     

    코드를 저장한 뒤, TodoListContainer가 잘 작동하는지 다시 확인해 보세요.

    신간 소식 구독하기
    뉴스레터에 가입하시고 이메일로 신간 소식을 받아 보세요.