# React 18 , handling events (6)

**URL:** <https://forum.codewithmosh.com/t/react-18-handling-events-6/20765>\
**Category:** React\
**Created:** [June 12, 2023, 12:19pm UTC](https://forum.codewithmosh.com/t/react-18-handling-events-6/20765 "2023-06-12T12:19:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![7\_hamo](https://avatars.discourse-cdn.com/v4/letter/7/fbc32d/32.png) [@7\_hamo](https://forum.codewithmosh.com/u/7_hamo)\
**Post date:** [June 12, 2023, 12:19pm UTC](https://forum.codewithmosh.com/t/react-18-handling-events-6/20765/1 "2023-06-12T12:19:54Z")

</div>

the problem came from TS , complaning in this code:  
onclick: {handleclick}

//the function  
const handleclick = (event: MouseEvent) =\> console.log(event);

the complaning message:

type ‘(event: MouseEvent) =\> void’ is not assignable to type ‘MouseEventHandler’.  
Types of parameters ‘event’ and ‘event’ are incompatible.  
Type ‘MouseEvent\<HTMLLIElement, MouseEvent\>’ is missing the following properties from type ‘MouseEvent’: offsetX, offsetY, x, y, and 14 more.ts(2322)  
index.d.ts(1521, 9): The expected type comes from property ‘onClick’ which is declared here on type ‘DetailedHTMLProps\<LiHTMLAttributes, HTMLLIElement\>’

---

<div class="post-metadata">

**Author:** ![BlotCoo](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/blotcoo/32/5976_2.png) [@BlotCoo](https://forum.codewithmosh.com/u/BlotCoo)\
**Post date:** [June 13, 2023, 12:09am UTC](https://forum.codewithmosh.com/t/react-18-handling-events-6/20765/2 "2023-06-13T00:09:41Z")

</div>

Sounds like TypeScript is complaining because it can’t infer the type of your function.

Either call your `handleclick` function inside an arrow function: `onClick={(event) => handleclick(event)}` or add the `MouseEventHandler` type to your `handleclick` function: `handleclick: MouseEventHandler = (event) => console.log(event);`
