Skip to content

Commit 8f4a110

Browse files
committed
Updating HTML babel example to valid HTML (W3C) and new react syntax
1 parent 2bfa7a6 commit 8f4a110

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed
Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
11
<!DOCTYPE html>
2-
<html>
2+
<html lang="en">
33
<head>
4-
<meta charset="UTF-8" />
4+
<meta charset="UTF-8">
55
<title>Hello World</title>
6-
<script src="https://unpkg.com/react@18/umd/react.development.js"></script>
7-
<script src="https://unpkg.com/react-dom@18/umd/react-dom.development.js"></script>
6+
<script src="https://unpkg.com/react@18.3.1/umd/react.development.js"></script>
7+
<script src="https://unpkg.com/react-dom@18.3.1/umd/react-dom.development.js"></script>
88

9-
<!-- Don't use this in production—do this: https://reactjs.org/docs/add-react-to-a-website#add-jsx-to-a-project -->
10-
<script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>
9+
<!-- Don't use this in production: -->
10+
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
1111
</head>
1212
<body>
1313
<div id="root"></div>
1414
<script type="text/babel">
1515

16-
ReactDOM.render(
17-
<h1>Hello, world!</h1>,
18-
document.getElementById('root')
19-
);
16+
function MyApp() {
17+
return <h1>Hello, world!</h1>;
18+
}
19+
20+
const container = document.getElementById('root');
21+
const root = ReactDOM.createRoot(container);
22+
root.render(<MyApp />);
2023

2124
</script>
2225
<!--
2326
Note: this page is a great way to try React but it's not suitable for production.
2427
It slowly compiles JSX with Babel in the browser and uses a large development build of React.
2528
26-
Read this section for a production-ready setup with JSX:
27-
https://reactjs.org/docs/docs/add-react-to-a-website#try-react-with-jsx
28-
29-
In a larger project, you can use an integrated toolchain that includes JSX instead:
30-
https://reactjs.org/docs/start-a-new-react-project
29+
Read this page for starting a new React project with JSX:
30+
https://react.dev/learn/start-a-new-react-project
3131
32-
You can also use React without JSX, in which case you can remove Babel:
33-
https://reactjs.org/docs/add-react-to-a-website#add-react-in-one-minute
32+
Read this page for adding React with JSX to an existing project:
33+
https://react.dev/learn/add-react-to-an-existing-project
3434
-->
3535
</body>
3636
</html>

0 commit comments

Comments
 (0)