D
D
DeniSidorenko2021-04-12 07:44:09
typescript
DeniSidorenko, 2021-04-12 07:44:09

Which argument to pass first in onClick Typescript?

Hello,

Is there such a function?

const onChangeHandler = (e:React.FormEvent<HTMLAnchorElement>, id:any) => {
    e.preventDefault()
    console.log(id)
  }


Used here
return(
                  <li key={index}>
                    <a href={"#"} onClick={onChangeHandler(Category.id)} >{Category.name}</a>
                  </li>
                )


But the function requires one more argument since the first one is React.FormEvent.
What should be the first argument in the onChangeHandler function?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Tigran Abrahamyan, 2021-04-12
@DeniSidorenko

onClick={(event: any) => onChangeHandler(event, Category.id)}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question