In your code this.fetchData("dfd")
you are calling the function. The function returns void
. void
is not assignable to onClick
which expects a function.
Fix
Create a new function that calls fetchData e.g. onClick={() => this.fetchData("dfd")}
.