Reputation: 15657
We were given the following example which did not include babel. How do I make it run without babel?
I use http-server -c-1 to start the npm server. Without babel I get a blank page
<!DOCTYPE html>
<html>
<head>
<title>hello</title>
<script src="react/react.js"></script>
<script src="react/react-dom.js"></script>
<!-- <script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>-->
<head>
<body>
<div id='container'>
<div>
</body>
<script type="text/jsx">
ReactDOM.render(
<h1>Hello1 React</h1>,
document.getElementById('container')
);
</script>
Upvotes: 0
Views: 450
Reputation: 1968
You cannot make this example run without babel. Babel is the library that takes your text/jsx
script and transforms it to plain javascript that your browser can parse and run.
You could however not use JSX and instead use React.createElement('h1', ...
to create your react application. (See https://reactjs.org/docs/react-without-jsx.html). But I would not recommend it.
Upvotes: 1