title: Add React component in HTML set by dangerouslySetInnerHTML
body: <p>I receive HTML from the server that needs to be injected via <code>dangerouslySetInnerHTML</code>. After inserting the HTML I want to get a DOM element with id: <code>home_content</code>. </p>
  
  <p>This is because I migrate from a legacy application(server-side rendered HTML) to React, the legacy application returns HTML. The goal of this React component is to parse the HTML from the legacy application to a React component. Within this component, I want to add React components to the initial HTML structure received from the server.</p>
  
  <pre><code>export default function App() {
    const [data, setData] = useState({});
    const [isLoading, setIsLoading] = useState(true);
    const didMountRef = useRef(false);
  
    const pageName = useSetPageTitle();
  
    // Will be replaced by the actual API call, Add to legacy component
    useEffect(() =&gt; {
      const fetchData = async () =&gt; {
        const response = await fetch(
          `http://127.0.0.1:8000/nav?action=${pageName}`
        );
        const legacyHTML = await response.text();
        setData(legacyHTML);
        setIsLoading(false);
      };
      fetchData();
  
      didMountRef.current = true;
    }, [pageName]);
  
    useEffect(() =&gt; {
      if(didMountRef.current) {
        const domContainer = document.querySelector("#home_content");
        ReactDOM.render(&lt;LikeButton /&gt;, domContainer);
      }
    }, [didMountRef]);
  
    return (
      &lt;&gt;
        &lt;LegacyDependencies /&gt;
        &lt;div&gt;
          &lt;div id="content"&gt;&lt;/div&gt;
          {isLoading ? (
            &lt;div&gt;
              &lt;span&gt;loading...&lt;/span&gt;
            &lt;/div&gt;
          ) : (
            &lt;div
              dangerouslySetInnerHTML={{
                __html: data,
              }}
            /&gt;
          )}
        &lt;/div&gt;
      &lt;/&gt;
    );
  }
  </code></pre>
  
  <p>I receive the following error: <code>Error: Target container is not a DOM element.</code></p>
  
  <p>Is it possible to add a React component to HTML inserted by <code>dangerouslySetInnerHTML</code>? </p>