Accepted answer

it will be pretty similar, create a new function that takes the number as argument and updates the state after removing the number from the valueslist.

const removenumberfromlist = (num: number) => {
  setvalueslist((prev) => prev.filter(el => el !== num))

// can be called like removenumberfromlist(10)
// or can be passed as onclick={() => removenumberfromlist(10)}

the type definition is pretty much the same

interface appprops {
  addnumbertolist: (num: number) => void;
  removenumberfromlist: (num: number) => void;


you can still use that filter bit of code, you just have to add types to it:

    setvalueslist((prev) => prev.filter((e:number) => e !== value));

Related Query

More Query from same tag