Answers for "handler for button in react typescript"

3

react onclick typescript type

onClick={(event: React.MouseEvent<HTMLElement>) => {
 makeMove(ownMark, (event.target as any).index)
}}
Posted by: Guest on July-11-2020
0

handler for button in react typescript

const handleAddToCart = (clickedItem: CartItemType) => {
    setCartItems(prev => {
      // 1. Is the item already added in the cart?
      const isItemInCart = prev.find(item => item.id === clickedItem.id);

      if (isItemInCart) {
        return prev.map(item =>
          item.id === clickedItem.id
            ? { ...item, amount: item.amount + 1 }
            : item
        );
      }
      // First time the item is added
      return [...prev, { ...clickedItem, amount: 1 }];
    });
  };
Posted by: Guest on September-06-2021
0

react typescript onclick type

interface IProps_Square {
  message: string;
  onClick: React.MouseEventHandler<HTMLButtonElement>;
}
Posted by: Guest on July-21-2021

Code answers related to "handler for button in react typescript"

Browse Popular Code Answers by Language