reactjsHow do I use a ReactJS CDN?
Using a ReactJS CDN is a great way to quickly add ReactJS to your project without any additional setup.
To use a ReactJS CDN, first include the following script tag in the <head>
of your HTML document:
<script crossorigin src="https://unpkg.com/react@16/umd/react.production.min.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.production.min.js"></script>
These two script tags will load the React and ReactDOM libraries from the CDN.
Once the libraries are loaded, you can use React components in your HTML document. Here is an example of a simple React component:
<div id="root"></div>
<script>
ReactDOM.render(
<h1>Hello, world!</h1>,
document.getElementById('root')
);
</script>
The code above will render the text "Hello, world!" in the <div>
with the id="root"
.
You can also use the ReactJS CDN to include the development version of React. To do this, replace the production.min.js
part of the script tag URLs with development.js
.
Helpful links
More of Reactjs
- How do I set the z-index of a ReactJS component?
- How can I use ReactJS and ZeroMQ together to create a distributed application?
- How do I zip multiple files using ReactJS?
- How can I convert an XLSX file to JSON using ReactJS?
- How do I create a zip file using ReactJS?
- How can I use ReactJS to zoom in and out of elements on a page?
- How can I use a ReactJS XML editor?
- How can I fix the "process is not defined" error when using ReactJS?
- How can I use zxcvbn in a ReactJS project?
- How can I become a React.js expert from scratch?
See more codes...