import * as React from "react"; const filterState = ["All", "Done", "Todo"] as const; export type FilterState = typeof filterState[number]; type Props = { value: FilterState; onChange: (value: FilterState) => void; }; export const Filter = ({ value, onChange }: Props) => { const handleClick = ( key: FilterState, e: React.MouseEvent ) => { e.preventDefault(); onChange(key); }; return (
{filterState.map((state) => ( handleClick(state, e)} className={state === value ? "is-active" : ""} > {state} ))}
); };