3 ms·
You can actually still do this, and it is kind of a shame it's not documented on react.dev You need to pull in react, plus Babel standalone, and then you can
by jameshart 4y ago
You can actually still do this, and it is kind of a shame it's not documented on react.dev
You need to pull in react, plus Babel standalone, and then you can use <script type="text/jsx"> tags, which means you can bootstrap react components onto your page. But you are going to be basically running a compiler in your user's web browser. That's fine if you want to run that way, but Babel has docs that explain why you probably shouldn't (https://babeljs.io/docs/babel-standalone#when-not-to-use-babelstandalone https://babeljs.io/docs/babel-standalone#when-not-to-use-bab...).
All you need is these two scripts:
<script crossorigin src="https://unpkg.com/@babel/standalone/babel.js"></script>
<script crossorigin src="https://unpkg.com/react@18/umd/react.development.js"></script>
[Edit - also need ReactDOM, sorry:
<script crossorigin src="https://unpkg.com/react-dom@18/umd/react-dom.development.js"></script>
]
I think it would help if more react tutorials started from here, because it shows why you need a build process.
Here, as a JSFiddle: the React 'Hello World' they don't want
you to see: https://jsfiddle.net/smLa1bco/ https://jsfiddle.net/smLa1bco/
- brailsafe 4y agoBuilding up my initial knowledge like you describe was the only way I could generate the enthusiasm for working on top of so many layers of abstraction.