<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Add React in One Minute</title>
</head>
<body>
<h2>Add React in One Minute</h2>
<p>This page demonstrates using React with no build tooling.</p>
<p>React is loaded as a script tag.</p>
<!-- We will put our React component inside this div. -->
<div id="like_button_container"></div>
<!-- Load React. -->
<!-- Note: when deploying, replace "development.js" with "production.min.js". -->
<script src="https://unpkg.com/react@16/umd/react.production.min.js" crossorigin></script>
<script src="https://unpkg.com/react-dom@16/umd/react-dom.production.min.js" crossorigin></script>
<!-- Load our React component. -->
<script src="like_button.js"></script>
</body>
</html>
Right, because you’re not using createElement in the manner it is written. JSX is referred to as ‘syntactic sugar’, a convenient layer over createElement. If you’re going to use createElement without that layer, you need to learn to use React without JSX.
The format for createElement should look more like:
const e = React.createElement;
return e(
'button',
{ /* any properties you may define, like onClick */},
'Click me!'
);
The parameters for createElement are Type, attributes, and content. But they aren’t simply the JSX, they are the actual values.
How do I get the js, the html to work together?
I don’t want the other stuff that imply using React.
I only need the html and the javascript and then use css style but this is not a problem.
Hahaha this would imply me rewriting the code of an entire application in javascript…
I could still use React but it doesn’t have to depend on the “create-react-app” I’ve did because I only need athe remaining files to be used with JBoss.
What, exactly, are you trying to do? Is it that you have a Like button component, built in React, that you’d like to parse to pure HTML/CSS/JS and use in a non-React page?
Yeah actually but it’s not just a button, it was just an example I was trying to make it work and then afterwards I would have inserted the entire App.jsx file inside of the file.
My poor understanding of React is the reason of all this mess. Using JBOSS without React is much more easier. Including a CDN would also be fine.
Not being familiar with React makes it so much worse, after the build I get a js map and another js file but I am unsure whether I can use that to make something like this.
But I need an entire project in React to be converted with all the import…