I have an API, which returns Json
with HTML
string like:
{
content: '<div><button class="some-class-name">Click me</button></div>'
}
class
, but notclassName
, but this is not the problem now.
I know that, I can render that HTML (NextJS):
<div dangerouslySetInnerHTML={{ __html: response.content }} />
The problem is the button, that has an event onClick
.
Is there a way or a package, which I can use for that - create components from a static HTML and bind events ?
1 possible way that I guess may works is to read the HTML
string extract the elements like (div
, button
) and create components from scratch.