reactjs - How do I change props from a child component using hooks? - Stack Overflow

PHOTO EMBED

Wed Nov 09 2022 15:11:29 GMT+0000 (Coordinated Universal Time)

Saved by @richard #javascript

interface CounterProps {
  num: number;
  setNum: React.Dispatch<React.SetStateAction<number>>;
}

const Counter: React.FC<CounterProps> = ({ num, setNum }) => {
  const handleClick = () => {
    setNum(num + 1);
  };

  return (
    // jsx codes...
  );
};
content_copyCOPY

https://stackoverflow.com/questions/59261671/how-do-i-change-props-from-a-child-component-using-hooks/