Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
import { selector } from "recoil";
import { todoListFilterState, todoListState } from "./atoms";
export const filteredTodoListState = selector({
key: "filteredTodoListState",
get: ({ get }) => {
const filter = get(todoListFilterState);
const list = get(todoListState);
switch (filter) {
case "completed":
return list.filter((item) => item.isCompleted);
case "uncompleted":
return list.filter((item) => !item.isCompleted);
// all
return list;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.