How to use React with Mojolicious web frame work.
Let's added the following code into a template file foo.html.ep
of Mojolicious after downloading React.
HTML Body
<div id="like_button_container"></div>
HTML Header
<script src="https://unpkg.com/react@18/umd/react.development.js" crossorigin></script>
<script src="https://unpkg.com/react-dom@18/umd/react-dom.development.js" crossorigin></script>
<script src="like_button.js"></script>
JavaScript
const domContainer = document.querySelector('#like_button_container');
const root = ReactDOM.createRoot(domContainer);
root.render(e(LikeButton));
See also
I use the codes of the following site.
https://ja.reactjs.org/docs/add-react-to-a-website.html#add-react-in-one-minute
For Beginners
Mojolicious is a Perl web frame work that support async I/O like node.js.
Top comments (0)