Within my React code base, I have a material-ui ListItem
that looks like this:
<ListItem button key={currIndex} onMouseOver={handleOnMouseClickOnListItem}>
The handler function in my code (using Flow typing) is as follows:
const handleOnMouseClickOnListItem: Event => void = (event: Event) => {
}
I want to pass the currIndex
parameter along with the existing event
parameter to my handleOnMouseClickOnListItem
function.
I attempted the following approach but encountered an error:
Cannot assign function to handleOnMouseClickOnListItem
because function requires another argument from function type
<ListItem button key={currIndex} onMouseOver={handleOnMouseClickOnListItem(currIndex)}>
const handleOnMouseClickOnListItem: Event => void = (event: Event, currIndex: number) => {
console.log(currIndex);
}
Updated -Non-flow Solution (based on accepted answer below)
https://codesandbox.io/s/amazing-rain-muor1?fontsize=14&hidenavigation=1&theme=dark