EDITED: I corrected how I do inject the code, it is not MDX related, it is simply plain html
I have html
code that I insert to my React page with
dangerouslySetInnerHTML={{ __html: myContent }}
Before, I've added some components to myContent
with a simple regex.replace()
, where I've replace some plain text with a React component transformed into plain html with
ReactDOMServer.renderToString(<Input type="text" ref={inputRef}/>)
*<Input>
is a styled component that returns a <input>
element
However, I cannot access to inputRef
, nor any onClick
or onChange
works
I do think that to enable these event listeners I should hydrate
the component? Don't really know how it would apply here, and don't really know if hydrate
is supposed to be applied in this user case (no server involved)
So the objective is that I can interact when this <input>
is changed, but so far it is absolutely static html that I cannot access to
What could I do?
At the end I've added an <input id="blah"...
and access it with vanilla JavaScript without any apparent trouble