import { atom } from'recoil';exportconsttodoFormModalOpenState=atom<boolean>({ // 할 일 등록 모달 key:'todoFormModalOpenState', default:false});
src/features/TodoList/atom.ts
import { atom, atomFamily, selectorFamily } from'recoil';import { isSameDay } from'../../utils/date';exportinterfaceTodo { id:string; content:string; done:boolean; date:Date;}exportconsttodoListState=atom<Array<Todo>>({ // 할 일 목록 key:'todoListState', default: [],});exportconstselectedDateState=atom<Date>({ // 선택한 날짜 key:'selectedDateState', default:newDate(),});exportconstselectedTodoState=atom<Todo|null>({ // 선택한 할 일 key:'selectedTodoState', default:null,});exportconstfilteredTodoListState=atomFamily<Array<Todo>,Date>({ // 선택한 날짜의 할 일 목록 key:'filteredTodoListState', default:selectorFamily({ key:'filteredTodoListState/default',get: (selectedDate) => ({ get }) => {consttodoList=get(todoListState);returntodoList.filter(todo =>isSameDay(todo.date, selectedDate)); } })});