Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
b099d55
Update conferences.md. Add a link on a live stream of a conference `<…
ntishkevich Mar 28, 2022
ac68ced
example should import useReducer (#4504)
Mar 28, 2022
74246c1
React 18 (#4499)
rickhanlonii Mar 29, 2022
34b0084
Next -> Next.js (#4508)
sebmarkbage Mar 29, 2022
8ee0706
Fix broken link (#4509)
mottox2 Mar 29, 2022
4725bbc
Clarify note for React Native users (#4512)
cortinico Mar 29, 2022
22b8bf2
Next -> Next.js (#4515)
styfle Mar 29, 2022
1138f7a
Fix link on upgrade to version 18 page (#4516)
igor-co Mar 29, 2022
c336758
Add missing word (#4514)
nickmorri Mar 29, 2022
41c3ca5
Document the new consistent Suspense behavior (#4517)
gaearon Mar 29, 2022
69ca55b
Fix usage of useDeferredValue (#4520)
SukkaW Mar 30, 2022
c623de4
fix useTransition link (#4519)
lilac-ss Mar 30, 2022
b5fd1df
Add a note about Strict Mode to release blog post (#4521)
gaearon Mar 30, 2022
f5c84d4
Update CDN links for React 18 (#4523)
Chalarangelo Mar 30, 2022
56a0dca
Update CDN links for React 18 (#4528)
Chalarangelo Mar 30, 2022
1c5a6c1
Update single-file example
gaearon Mar 30, 2022
0982707
Update StrictMode docs about double logging (#4531)
gaearon Mar 30, 2022
c77e2f2
Fix typo in Automatic Batching example (#4532)
hyupee Mar 31, 2022
e34da98
reword challenge 2 (#4536)
armenic Apr 2, 2022
e826e66
Change redirect from WG post to the blog (#4537)
gaearon Apr 2, 2022
2666c95
Added React Day Bangalore 2022 (#4539)
akiran Apr 3, 2022
ec2dcbc
Update Prerequisites nodejs version (#4538)
Apr 3, 2022
707f22d
Add call to action to 18 blog post (#4542)
gaearon Apr 3, 2022
1298e4e
merging all conflicts
react-translations-bot Apr 4, 2022
95cee0c
resolve merge conflicts
carburo Apr 4, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions beta/public/html/single-file-example.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<head>
<meta charset="UTF-8" />
<title>Hello World</title>
<script src="https://unpkg.com/react@17/umd/react.development.js"></script>
<script src="https://unpkg.com/react-dom@17/umd/react-dom.development.js"></script>
<script src="https://unpkg.com/react@18/umd/react.development.js"></script>
<script src="https://unpkg.com/react-dom@18/umd/react-dom.development.js"></script>

<!-- Don't use this in production—do this: https://reactjs.org/docs/add-react-to-a-website#add-jsx-to-a-project -->
<script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>
</head>
Expand Down
4 changes: 2 additions & 2 deletions beta/src/pages/apis/reactdom.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ npm install react-dom

```js
// Importing a specific API:
import { render } from 'react-dom';
import { createRoot } from 'react-dom/client';

// Importing all APIs together:
import * as ReactDOM from 'react';
import * as ReactDOMClient from 'react-dom/client';
```

</PackageImport>
Expand Down
2 changes: 1 addition & 1 deletion beta/src/pages/apis/usereducer.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const [state, dispatch] = useReducer(reducer, initialArg, init)
Call `useReducer` at the top level of your component to manage state with a [reducer](/learn/extracting-state-logic-into-a-reducer).

```js [[1, 8, "state"], [2, 8, "dispatch"], [4, 8, "reducer"], [3, 8, "{ age: 42 }"]]
import { useState } from 'react';
import { useReducer } from 'react';

function reducer(state, action) {
// ...
Expand Down
35 changes: 18 additions & 17 deletions beta/src/pages/learn/add-react-to-a-website.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ You can place a "container" element like this `<div>` anywhere inside the `<body

In the HTML page, right before the closing `</body>` tag, add three `<script>` tags for the following files:

- [**react.development.js**](https://unpkg.com/react@17/umd/react.development.js) loads the core of React
- [**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).
- [**react.development.js**](https://unpkg.com/react@18/umd/react.development.js) loads the core of React
- [**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).
- **like_button.js** is where you'll write your component in step 3!

<Gotcha>
Expand All @@ -42,8 +42,8 @@ When deploying, replace "development.js" with "production.min.js".

```html
<!-- end of the page -->
<script src="https://unpkg.com/react@17/umd/react.development.js" crossorigin></script>
<script src="https://unpkg.com/react-dom@17/umd/react-dom.development.js" crossorigin></script>
<script src="https://unpkg.com/react@18/umd/react.development.js" crossorigin></script>
<script src="https://unpkg.com/react-dom@18/umd/react-dom.development.js" crossorigin></script>
<script src="like_button.js"></script>
</body>
```
Expand Down Expand Up @@ -74,11 +74,12 @@ function LikeButton() {

### Step 4: Add your React Component to the page {/*step-4-add-your-react-component-to-the-page*/}

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.
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.

```js
const domContainer = document.getElementById('component-goes-here');
ReactDOM.render(React.createElement(LikeButton), domContainer);
const root = ReactDOM.createRoot(domContainer);
root.render(React.createElement(LikeButton));
```

**Congratulations! You have just rendered your first React component to your website!**
Expand All @@ -88,21 +89,21 @@ ReactDOM.render(React.createElement(LikeButton), domContainer);

#### You can reuse components! {/*you-can-reuse-components*/}

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.
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.

1. In **index.html**, add an additional container element `<div id="component-goes-here-too"></div>`.
2. In **like_button.js**, add an additional `ReactDOM.render()` for the new container element:

```js {6,7,8,9}
ReactDOM.render(
React.createElement(LikeButton),
const root1 = ReactDOM.createRoot(
document.getElementById('component-goes-here')
);
root1.render(React.createElement(LikeButton));

ReactDOM.render(
React.createElement(LikeButton),
const root2 = ReactDOM.createRoot(
document.getElementById('component-goes-here-too')
);
root2.render(React.createElement(LikeButton));
```

Check out [an example that displays the "Like" button three times and passes some data to it](https://gist.github.com/rachelnabors/c0ea05cc33fbe75ad9bbf78e9044d7f8)!
Expand All @@ -115,8 +116,8 @@ Unminified JavaScript can significantly slow down page load times for your users
- **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:

```html
<script src="https://unpkg.com/react@17/umd/react.production.min.js" crossorigin></script>
<script src="https://unpkg.com/react-dom@17/umd/react-dom.production.min.js" crossorigin></script>
<script src="https://unpkg.com/react@18/umd/react.production.min.js" crossorigin></script>
<script src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js" crossorigin></script>
```

## Try React with JSX {/*try-react-with-jsx*/}
Expand Down Expand Up @@ -144,8 +145,8 @@ The quickest way to try JSX in your project is to add the Babel compiler to your
```html {6}
<!-- ... rest of <head> ... -->

<script src="https://unpkg.com/react@17/umd/react.production.min.js" crossorigin></script>
<script src="https://unpkg.com/react-dom@17/umd/react-dom.production.min.js" crossorigin></script>
<script src="https://unpkg.com/react@18/umd/react.production.min.js" crossorigin></script>
<script src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js" crossorigin></script>

<script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>

Expand All @@ -157,8 +158,8 @@ Now you can use JSX in any `<script>` tag by adding `type="text/babel"` attribut

```jsx {1}
<script type="text/babel">
ReactDOM.render(
<h1>Hello, world!</h1>, document.getElementById('root') );
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<h1>Hello, world!</h1>);
</script>
```

Expand Down
2 changes: 1 addition & 1 deletion beta/src/pages/learn/choosing-the-state-structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -2019,7 +2019,7 @@ export default function App() {

### Fix a broken packing list {/*fix-a-broken-packing-list*/}

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.
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.

<Hint>

Expand Down
3 changes: 3 additions & 0 deletions content/authors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ petehunt:
rachelnabors:
name: Rachel Nabors
url: https://twitter.com/rachelnabors
reactteam:
name: The React Team
url: https://reactjs.org/community/team.html
rickhanlonii:
name: Rick Hanlon
url: https://twitter.com/rickhanlonii
Expand Down
Loading