Skip to content

Commit a9b0ebd

Browse files
committed
Merge branch 'main' of github.com:reactjs/reactjs.org
2 parents e73fbaa + fc7bd4d commit a9b0ebd

File tree

13 files changed

+49
-25
lines changed

13 files changed

+49
-25
lines changed

beta/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"check-all": "npm-run-all prettier lint:fix tsc"
2323
},
2424
"dependencies": {
25-
"@codesandbox/sandpack-react": "1.14.1",
25+
"@codesandbox/sandpack-react": "1.15.5",
2626
"@docsearch/css": "3.0.0-alpha.41",
2727
"@docsearch/react": "3.0.0-alpha.41",
2828
"@headlessui/react": "^1.7.0",

beta/src/components/Icon/IconGitHub.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ export const IconGitHub = memo<JSX.IntrinsicElements['svg']>(
88
function IconGitHub(props) {
99
return (
1010
<svg
11-
width="1em"
11+
xmlns="http://www.w3.org/2000/svg"
12+
width="1.33em"
13+
height="1.33em"
14+
viewBox="0 -2 24 24"
1215
fill="currentColor"
13-
height="1em"
14-
viewBox="0 0 20 20"
1516
{...props}>
1617
<path d="M10 0a10 10 0 0 0-3.16 19.49c.5.1.68-.22.68-.48l-.01-1.7c-2.78.6-3.37-1.34-3.37-1.34-.46-1.16-1.11-1.47-1.11-1.47-.9-.62.07-.6.07-.6 1 .07 1.53 1.03 1.53 1.03.9 1.52 2.34 1.08 2.91.83.1-.65.35-1.09.63-1.34-2.22-.25-4.55-1.11-4.55-4.94 0-1.1.39-1.99 1.03-2.69a3.6 3.6 0 0 1 .1-2.64s.84-.27 2.75 1.02a9.58 9.58 0 0 1 5 0c1.91-1.3 2.75-1.02 2.75-1.02.55 1.37.2 2.4.1 2.64.64.7 1.03 1.6 1.03 2.69 0 3.84-2.34 4.68-4.57 4.93.36.31.68.92.68 1.85l-.01 2.75c0 .26.18.58.69.48A10 10 0 0 0 10 0"></path>
1718
</svg>

beta/src/components/Layout/Footer.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import ButtonLink from 'components/ButtonLink';
99
import {ExternalLink} from 'components/ExternalLink';
1010
import {IconFacebookCircle} from 'components/Icon/IconFacebookCircle';
1111
import {IconTwitter} from 'components/Icon/IconTwitter';
12+
import {IconGitHub} from 'components/Icon/IconGitHub';
1213
import {IconNavArrow} from 'components/Icon/IconNavArrow';
1314

1415
export function Footer() {
@@ -160,6 +161,12 @@ export function Footer() {
160161
className={socialLinkClasses}>
161162
<IconTwitter />
162163
</ExternalLink>
164+
<ExternalLink
165+
aria-label="React on Github"
166+
href="https://github.com/reactjs/reactjs.org"
167+
className={socialLinkClasses}>
168+
<IconGitHub />
169+
</ExternalLink>
163170
</div>
164171
</div>
165172
</div>

beta/src/content/apis/react/cloneElement.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const clonedElement = cloneElement(element, props, ...children)
2929
To override the props of some <CodeStep step={1}>React element</CodeStep>, pass it to `cloneElement` with the <CodeStep step={2}>props you want to override</CodeStep>:
3030

3131
```js [[1, 5, "<Row title=\\"Cabbage\\" />"], [2, 6, "{ isHighlighted: true }"], [3, 4, "clonedElement"]]
32-
import { clonedElement } from 'react';
32+
import { cloneElement } from 'react';
3333

3434
// ...
3535
const clonedElement = cloneElement(
@@ -650,7 +650,7 @@ This approach is particularly useful if you want to reuse this logic between dif
650650
Call `cloneElement` to create a React element based on the `element`, but with different `props` and `children`:
651651

652652
```js
653-
import { clonedElement } from 'react';
653+
import { cloneElement } from 'react';
654654
655655
// ...
656656
const clonedElement = cloneElement(

beta/src/content/apis/react/createFactory.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ This lets you keep all of your code unchanged except the imports.
104104

105105
### Replacing `createFactory` with `createElement` {/*replacing-createfactory-with-createelement*/}
106106

107-
If you have a few `createFactory` calls that you don't mind porting manually, and you don't want to use JSX, you can replace every call a factory function with a [`createElement`](/api/react/createElement) call. For example, you can replace this code:
107+
If you have a few `createFactory` calls that you don't mind porting manually, and you don't want to use JSX, you can replace every call a factory function with a [`createElement`](/apis/react/createElement) call. For example, you can replace this code:
108108

109109
```js {1,3,6}
110110
import { createFactory } from 'react';

beta/src/content/apis/react/isValidElement.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Call `isValidElement` to check if some value is a *React element.*
2525
React elements are:
2626

2727
- Values produced by writing a [JSX tag](/learn/writing-markup-with-jsx)
28-
- Values produced by calling [`createElement`](/api/react/createElement)
28+
- Values produced by calling [`createElement`](/apis/react/createElement)
2929

3030
For React elements, `isValidElement` returns `true`:
3131

@@ -55,7 +55,7 @@ console.log(isValidElement([<div />, <div />])); // false
5555
console.log(isValidElement(MyComponent)); // false
5656
```
5757

58-
It is very uncommon to need `isValidElement`. It's mostly useful if you're calling another API that *only* accepts elements (like [`cloneElement`](/api/react/cloneElement) does) and you want to avoid an error when your argument is not a React element.
58+
It is very uncommon to need `isValidElement`. It's mostly useful if you're calling another API that *only* accepts elements (like [`cloneElement`](/apis/react/cloneElement) does) and you want to avoid an error when your argument is not a React element.
5959

6060
Unless you have some very specific reason to add an `isValidElement` check, you probably don't need it.
6161

@@ -123,4 +123,4 @@ console.log(isValidElement({ age: 42 })); // false
123123

124124
#### Caveats {/*caveats*/}
125125

126-
* **Only [JSX tags](/learn/writing-markup-with-jsx) and objects returned by [`createElement`](/api/react/createElement) are considered to be React elements.** For example, even though a number like `42` is a valid React *node* (and can be returned from a component), it is not a valid React element. Arrays and portals created with [`createPortal`](/apis/react-dom/createPortal) are also *not* considered to be React elements.
126+
* **Only [JSX tags](/learn/writing-markup-with-jsx) and objects returned by [`createElement`](/apis/react/createElement) are considered to be React elements.** For example, even though a number like `42` is a valid React *node* (and can be returned from a component), it is not a valid React element. Arrays and portals created with [`createPortal`](/apis/react-dom/createPortal) are also *not* considered to be React elements.

beta/src/content/apis/react/lazy.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ const MarkdownPreview = lazy(() => import('./MarkdownPreview.js'));
173173

174174
#### Returns {/*load-returns*/}
175175

176-
You need to return a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) or some other *thenable* (a Promise-like object with a `then` method). It needs to eventually resolve to a valid React component type, such as a function, [`memo`](/api/react/memo), or a [`forwardRef`](/api/react/forwardRef) component.
176+
You need to return a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) or some other *thenable* (a Promise-like object with a `then` method). It needs to eventually resolve to a valid React component type, such as a function, [`memo`](/apis/react/memo), or a [`forwardRef`](/apis/react/forwardRef) component.
177177

178178
---
179179

beta/src/content/apis/react/memo.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ To make your component re-render only when a _part_ of some context changes, spl
242242
When you use `memo`, your component re-renders whenever any prop is not *shallowly equal* to what it was previously. This means that React compares every prop in your component with the previous value of that prop using the [`Object.is`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is) comparison. Note that `Object.is(3, 3)` is `true`, but `Object.is({}, {})` is `false`.
243243

244244

245-
To get the most out of `memo`, minimize the times that the props change. For example, if the prop is an object, prevent the parent component from re-creating that object every time by using [`useMemo`:](/api/react/useMemo)
245+
To get the most out of `memo`, minimize the times that the props change. For example, if the prop is an object, prevent the parent component from re-creating that object every time by using [`useMemo`:](/apis/react/useMemo)
246246

247247
```js {5-8}
248248
function Page() {

beta/src/content/apis/react/useCallback.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ function ProductPage({ productId, referrer, theme }) {
116116
}
117117
```
118118
119-
**By wrapping `handleSubmit` in `useCallback`, you ensure that it's the *same* function between the re-renders** (until dependencies change). You don't *have to* wrap a function in `useCallback` unless you do it for some specific reason. In this example, the reason is that you pass it to a component wrapped in [`memo`,](/api/react/memo) and this lets it skip re-rendering. There are a few other reasons you might need `useCallback` which are described further on this page.
119+
**By wrapping `handleSubmit` in `useCallback`, you ensure that it's the *same* function between the re-renders** (until dependencies change). You don't *have to* wrap a function in `useCallback` unless you do it for some specific reason. In this example, the reason is that you pass it to a component wrapped in [`memo`,](/apis/react/memo) and this lets it skip re-rendering. There are a few other reasons you might need `useCallback` which are described further on this page.
120120
121121
<Note>
122122
@@ -856,7 +856,7 @@ When you find which dependency is breaking memoization, either find a way to rem
856856
857857
### I need to call `useCallback` for each list item in a loop, but it's not allowed {/*i-need-to-call-usememo-for-each-list-item-in-a-loop-but-its-not-allowed*/}
858858
859-
Suppose the `Chart` component is wrapped in [`memo`](/api/react/memo). You want to skip re-rendering every `Chart` in the list when the `ReportList` component re-renders. However, you can't call `useCallback` in a loop:
859+
Suppose the `Chart` component is wrapped in [`memo`](/apis/react/memo). You want to skip re-rendering every `Chart` in the list when the `ReportList` component re-renders. However, you can't call `useCallback` in a loop:
860860
861861
```js {5-14}
862862
function ReportList({ items }) {
@@ -906,7 +906,7 @@ function Report({ item }) {
906906
}
907907
```
908908
909-
Alternatively, you could remove `useCallback` in the last snippet and instead wrap `Report` itself in [`memo`.](/api/react/memo) If the `item` prop does not change, `Report` will skip re-rendering, so `Chart` will skip re-rendering too:
909+
Alternatively, you could remove `useCallback` in the last snippet and instead wrap `Report` itself in [`memo`.](/apis/react/memo) If the `item` prop does not change, `Report` will skip re-rendering, so `Chart` will skip re-rendering too:
910910
911911
```js {5,6-8,15}
912912
function ReportList({ items }) {

beta/src/content/apis/react/useEffect.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1651,7 +1651,7 @@ function Page({ url, shoppingCart }) {
16511651
}
16521652
```
16531653
1654-
**What if you want to log a new page visit after every `url` change, but *not* if only the `shoppingCart` changes?** You can't exclude `shoppingCart` from dependencies without breaking the [reactivity rules.](#specifying-reactive-dependencies) However, you can express that you *don't want* a piece of code to "react" to changes even though it is called from inside an Effect. To do this, [declare an *Event function*](/learn/separating-events-from-effects#declaring-an-event-function) with the [`useEvent`](/api/react/useEvent) Hook, and move the code that reads `shoppingCart` inside of it:
1654+
**What if you want to log a new page visit after every `url` change, but *not* if only the `shoppingCart` changes?** You can't exclude `shoppingCart` from dependencies without breaking the [reactivity rules.](#specifying-reactive-dependencies) However, you can express that you *don't want* a piece of code to "react" to changes even though it is called from inside an Effect. To do this, [declare an *Event function*](/learn/separating-events-from-effects#declaring-an-event-function) with the [`useEvent`](/apis/react/useEvent) Hook, and move the code that reads `shoppingCart` inside of it:
16551655
16561656
```js {2-4,7,8}
16571657
function Page({ url, shoppingCart }) {

0 commit comments

Comments
 (0)