0

In my click event for React I have specified a type for the event, but for some reason it says

type value is not on the event type

Code so far is:

type ButtonEvent = React.MouseEvent<HTMLButtonElement>;

<Button variant="primary" onClick={(event: ButtonEvent): void => alert(event.target.value)}>Primary</Button>

I can't seem to use event.target.value, any idea's why?

Rifky Niyas
  • 1,737
  • 10
  • 25
Sole
  • 3,100
  • 14
  • 58
  • 112
  • Does this answer your question? [Typescript input onchange event.target.value](https://stackoverflow.com/questions/40676343/typescript-input-onchange-event-target-value) – Heretic Monkey Aug 31 '21 at 12:02

1 Answers1

0

you should add property value to your Button :

<Button value="what you want" variant="primary" onClick={(event: ButtonEvent): void => alert(event.target.value)}>Primary</Button>
Nokwiw
  • 386
  • 4
  • 11