First of all you need to add Babel to transpile your JSX which here is how you would do that by adding this line to your html file:
<script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>
and then you need is to add the type property to your InputField script like this:
<script type="text/babel" src="InputField.js"></script>
Here is the complete code:
<!-- ... existing HTML ... -->
<div id="like_button_container"></div>
<!-- ... existing HTML ... -->
<!-- Load React. -->
<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>
<!-- Babel js -->
<script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>
<!-- Load our React component. -->
<script type="text/babel" src="InputField.js"></script>
</body>
Answer from Taghi Khavari on Stack OverflowInfoheap
infoheap.com › home › online tools › online lint
Online React jsx to javascript transformer using babel-cli - InfoHeap
This online transformer can be used to compile react jsx to Javascript using babel-cli.
Babel
babeljs.io › repl
REPL de Babel
Skip to main content
reactjs - How to convert react JSX files to simple JavaScript file [offline transformation] - Stack Overflow
If you are using babel-cli you need to use a plugin to transform jsx syntax to js syntax that the browser understands. See the following link: http://babeljs.io/docs/plugins/transform-react-jsx/ You'll need to install babel-plugin-transform-react-jsx plugin and use it in a .babelrc file like that: More on stackoverflow.com
reactjs - React.js - convert .jsx to .js - Stack Overflow
I'm totally new to React...how do I convert a .jsx file to .js? I tried to use Babel via CLI but the command doesn't even work: babel --plugins transform-react-jsx board.jsx I also tried replacing " More on stackoverflow.com
Tool to transpile from js to jsx - javascript
I'm curious if any of the transpiling tools will convert from plain JS to JSX. Babel will transpile JSX to JS, but as far as I know it cannot go back to JSX. From the example: var Nav; // Input (... More on stackoverflow.com
What’s the difference between .js & .jsx extension
.jsx was introduced to tell tools that the file contains JSX syntax (the html in JavaScript stuff that react invented). If you don’t have html in your file you can use .js. This is probably best practice for utilities and hook files if they don’t have jsx as compilation/parsing is simpler and it hints to other people what the file does. So basically .js doesn’t support doing: return something; But I imagine tooling has become lenient over time and doesn’t care about the extension. More on reddit.com
27:31
Learning ReactJS: Converting Vanilla JavaScript into ReactJS - YouTube
01:02:22
Converting A Plain JavaScript App To React - YouTube
13:15
JSX in React JS in Hindi in 2020 #6 - YouTube
06:59
React JS Tutorial - JSX and Babel #3 - YouTube
07:02
YouTube
29:29
Convert HTML to JSX - YouTube
Jsontotable
jsontotable.org › jsx-to-javascript
JSX to JavaScript Converter - Convert JSX to React.createElement | JSON to Table Converter
Free online JSX to JavaScript converter.
Convert.Guru
convert.guru › jsx-converter
.JSX Converter - Convert React & Adobe Scripts to JS, TS, TXT files
Convert or analyse your React component and Adobe ExtendScript .JSX files online for free to .JS, .TXT, .PDF, or anything else. The .JSX file extension has two distinct primary uses.
Transform
transform.tools
Transform
to JSX · to Pug · to Big Query Schema · to Flow · to Go Bson · to Go Struct · to GraphQL · to io-ts · to Java · to JSDoc · to JSON Schema · to Kotlin · to MobX-State-Tree Model · to Mongoose Schema · to MySQL · to React PropTypes · to Rust Serde ·
React
legacy.reactjs.org › blog › 2020 › 09 › 22 › introducing-the-new-jsx-transform.html
Introducing the New JSX Transform – React Blog
September 22, 2020 - Browsers don’t understand JSX out of the box, so most React users rely on a compiler like Babel or TypeScript to transform JSX code into regular JavaScript. Many preconfigured toolkits like Create React App or Next.js also include a JSX transform under the hood.
DEV Community
dev.to › kashif_ullah_dev › how-react-jsx-gets-transformed-into-javascript-behind-the-scenes-467f
How React JSX Gets Transformed Into JavaScript Behind the Scenes - DEV Community
September 23, 2024 - 2.Babel transforms it – During the build process, Babel converts the JSX into pure JavaScript using React.createElement: const element = React.createElement('h1', null, 'Hello, World!'); 3.JavaScript in the browser – Finally, this standard JavaScript is what the browser executes, building the DOM dynamically. Babel is a powerful JavaScript compiler that enables you to use the latest JavaScript features (including JSX in React) while ensuring compatibility across different browsers and environments.
Toolsnip
toolsnip.com › tools › jsx-to-javascript
Free JSX to JavaScript Converter - Convert JSX to JS Online | ToolSnip | ToolSnip
Convert JSX syntax to plain JavaScript instantly. Transform React JSX components to vanilla JavaScript. Free online JSX to JavaScript converter.
Amnuts
blog.amnuts.com › 2016 › 07 › 13 › converting-jsx-to-js-on-the-command-line
Converting JSX to JS on the command line – Andy's blog o' goodness
July 22, 2016 - Obviously you’d change the --out-dir to wherever you’d want to output the .js file. So now when I change a file in my jsx folder, such as components.jsx, it will create the equivalently name components.js file, correct transpiled and converted from JSX (and ES2015 arrow functions) to good ol’ javascript with ES5 bind methods.
Mohebifar
mohebifar.github.io › vidact
Vidact - A compiler to convert React-like apps to VanillaJS
We cannot provide a description for this page right now
BigBinary Academy
courses.bigbinaryacademy.com › learn-react › more-on-jsx › how-jsx-is-converted-to-js
How JSX is converted to JavaScript - Learn React | BigBinary Academy
Browsers don't understand JSX. It only understands HTML, CSS and JavaScript. Therefore, the code written in JSX needs to be converted to plain JavaScript. Babel is a toolchain that helps perform this conversion. Babel was introduced to help developers use new ECMA standard syntaxes without ...
Top answer 1 of 2
1
If you are using babel-cli you need to use a plugin to transform jsx syntax to js syntax that the browser understands. See the following link: http://babeljs.io/docs/plugins/transform-react-jsx/ You'll need to install babel-plugin-transform-react-jsx plugin and use it in a .babelrc file like that:
{
"plugins": ["transform-react-jsx"]
}
Then your babel command should work.
2 of 2
0
Try babel --presets react JSX_Files --watch --out-dir public/javascripts (s on the end of preset).
Transform
transform.tools › html-to-jsx
HTML to JSX
An online playground to convert HTML to JSX
React
legacy.reactjs.org › jsx-compiler.html
JSX Compiler Service
This tool has been removed as JSXTransformer has been deprecated.
Stack Overflow
stackoverflow.com › questions › 49714230 › react-js-convert-jsx-to-js
reactjs - React.js - convert .jsx to .js - Stack Overflow
August 4, 2018 - The error above is from npx. You haven't touched babel yet. ... No, I'm not.... ... I installed babel locally in my project, then I ran the command "babel --plugins transform-react-jsx board.js", but it doesn't work, it says it's not recognized as a command. Then people are saying I have to pass the path where babel is locally installed, and i tried "./node_modules/.bin/babel --plugins transform-react-jsx board.js", but still the same error message.
GitHub
gist.github.com › Reeska › 05c11a296f90b76548cec45b23674f71
A script to convert .js to .jsx when they contains JSX tags · GitHub
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters ... This script will scans the files in the given directory and renames all .js files that contains JSX tags to .jsx files.