You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: beta/src/pages/learn/add-react-to-a-website.md
+18-17Lines changed: 18 additions & 17 deletions
Original file line number
Diff line number
Diff line change
@@ -30,8 +30,8 @@ You can place a "container" element like this `<div>` anywhere inside the `<body
30
30
31
31
In the HTML page, right before the closing `</body>` tag, add three `<script>` tags for the following files:
32
32
33
-
-[**react.development.js**](https://unpkg.com/react@17/umd/react.development.js) loads the core of React
34
-
-[**react-dom.development.js**](https://unpkg.com/react-dom@17/umd/react-dom.development.js) lets React render HTML elements to the [DOM](https://developer.mozilla.org/docs/Web/API/Document_Object_Model).
33
+
-[**react.development.js**](https://unpkg.com/react@18/umd/react.development.js) loads the core of React
34
+
-[**react-dom.development.js**](https://unpkg.com/react-dom@18/umd/react-dom.development.js) lets React render HTML elements to the [DOM](https://developer.mozilla.org/docs/Web/API/Document_Object_Model).
35
35
-**like_button.js** is where you'll write your component in step 3!
36
36
37
37
<Gotcha>
@@ -42,8 +42,8 @@ When deploying, replace "development.js" with "production.min.js".
### Step 4: Add your React Component to the page {/*step-4-add-your-react-component-to-the-page*/}
76
76
77
-
Lastly, add two lines to the bottom of **like_button.js**. These two lines of code find the `<div>` you added to your HTML in the first step and then display the "Like" button React component inside of it.
77
+
Lastly, add three lines to the bottom of **like_button.js**. These three lines of code find the `<div>` you added to your HTML in the first step, create a React app with it, and then display the "Like" button React component inside of it.
#### You can reuse components! {/*you-can-reuse-components*/}
90
91
91
-
You might want to display a React component in multiple places on the same HTML page. This is most useful while React-powered parts of the page are isolated from each other. You can do this by calling `ReactDOM.render()` multiple times with multiple container elements.
92
+
You might want to display a React component in multiple places on the same HTML page. This is most useful while React-powered parts of the page are isolated from each other. You can do this by calling `ReactDOM.createRoot()` multiple times with multiple container elements.
92
93
93
94
1. In **index.html**, add an additional container element `<div id="component-goes-here-too"></div>`.
94
95
2. In **like_button.js**, add an additional `ReactDOM.render()` for the new container element:
Check out [an example that displays the "Like" button three times and passes some data to it](https://gist.github.com/rachelnabors/c0ea05cc33fbe75ad9bbf78e9044d7f8)!
@@ -115,8 +116,8 @@ Unminified JavaScript can significantly slow down page load times for your users
115
116
-**If you already minify** your application scripts, your site will be production-ready if you ensure that the deployed HTML loads the versions of React ending in `production.min.js` like so:
Copy file name to clipboardExpand all lines: beta/src/pages/learn/choosing-the-state-structure.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -2019,7 +2019,7 @@ export default function App() {
2019
2019
2020
2020
### Fix a broken packing list {/*fix-a-broken-packing-list*/}
2021
2021
2022
-
This packing list has a footer that shows how many items are packed, and how many items there are overall. It seems to work at first, but it is buggy. For example, if you mark a place as completed and then delete it, the counter will not be updated correctly. Fix the counter so that it's always correct.
2022
+
This packing list has a footer that shows how many items are packed, and how many items there are overall. It seems to work at first, but it is buggy. For example, if you mark an item as packed and then delete it, the counter will not be updated correctly. Fix the counter so that it's always correct.
0 commit comments