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 can I use zxcvbn in a ReactJS project?
- How do I create a video with ReactJS?
- How can I use ReactJS and ZeroMQ together to create a distributed application?
- How do I zip multiple files using ReactJS?
- How do I set the z-index of a ReactJS component?
- How do I create a zip file using ReactJS?
- How do I use ReactJS to create an example XLSX file?
- What is React.js and how is it used in software development?
- How do I set the z-index of an element in React.js?
- How can I use ReactJS to create a REST API?
See more codes...