score:1

you can write react code simply by loading the react libraries through <script> tag in the <head> element, as long as you select the html element in your react code

for example if you wanted to code a like button in react, in html you give a unique id:

<div id="like_button_container"></div>

then, in javascript you select the element and render with react:

const domcontainer = document.queryselector('#like_button_container');
reactdom.render(e(likebutton), domcontainer);

full example can be found here by dan abramov: https://gist.github.com/gaearon/6668a1f6986742109c00a581ce704605


so in webpack, we'll just have to find ways to add the <script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js" crossorigin></script> to the <head> element somehow. depends how you've set up your index.html, you can either 1) add the script tag directly into index.html or 2) use plugins such as html-webpack-pluign to dynamically generate the index.html


Related Query

More Query from same tag