I have a html string embedded in a map function like this
pnp.sp.web.lists.getByTitle("Division").items.select("Title","ID").get().then((item: any[]) => divtree=item.map(per =>'<li id='+per.Title+' style="cursor:pointer" onclick="myfunction()" >'+per.Title+'</li>');
divtree.toString().replace(/,/g , "");});
this.setState({
divtree: divtree
});
This is used in return like this
<div dangerouslySetInnerHTML={{__html: this.state.divtree}} ></div>
I m declaring the function myfunction() like this
private myfunction(): void { console.log('working') }
My problem is that when I click on the li element which was created dynamically I get the error myfunction() function is not defined