简体   繁体   中英

Add React app to static HTML page from another folder

I created a react app with multiple components as part of something bigger and I want to display that react app in a HTML page. I saw other posts but they had everything in a script file with the component in the script tag itself. I have a fully functioning chat app in another folder and I wanted to render that in the HTML file.


<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="html_container">

    </div>


    <script src="./reactApp/src/App.js">
        <!-- add some magic here to have the app from the folder show up here -->
        ReactDOM.render(
            <App />,
            document.getElementById('html_container')
        );
    </script>
</body>
</html>


You could use an iframe to render the react app inside the page, with the src linking to your react app.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM