TypeScript interface signature for the onClick event in ReactJS

The interface with props should be

interface IProps_Square {
  message: string;
  onClick: React.MouseEventHandler<HTMLButtonElement>;
}

Notice also that if you use semicolons, the interface items separator is a semicolon, not a comma.

Another hint: I recommend type rather than interface for props. They are almost the same, the only difference I found is that interface may be extended anywhere in the code, in fact it is used for globals.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)