Skip to content

Commit 40a7976

Browse files
Merge branch 'main' of https://github.com/reactjs/react.dev into sync-7ea43a8d
2 parents 62cd321 + 7ea43a8 commit 40a7976

File tree

4 files changed

+36
-25
lines changed

4 files changed

+36
-25
lines changed

.github/workflows/analyze.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
# Here's the first place where next-bundle-analysis' own script is used
3939
# This step pulls the raw bundle stats for the current bundle
4040
- name: Analyze bundle
41-
run: npx -p nextjs-bundle-analysis report
41+
run: npx -p nextjs-bundle-analysis@0.5.0 report
4242

4343
- name: Upload bundle
4444
uses: actions/upload-artifact@v2

.github/workflows/analyze_comment.yml

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -47,26 +47,9 @@ jobs:
4747
pr_number=$(cat pr_number/pr_number)
4848
echo "pr-number=$pr_number" >> $GITHUB_OUTPUT
4949
50-
- name: Find Comment
51-
uses: peter-evans/find-comment@v1
52-
if: success()
53-
id: fc
54-
with:
55-
issue-number: ${{ steps.get-comment-body.outputs.pr-number }}
56-
body-includes: "<!-- __NEXTJS_BUNDLE -->"
57-
58-
- name: Create Comment
59-
uses: peter-evans/[email protected]
60-
if: success() && steps.fc.outputs.comment-id == 0
61-
with:
62-
issue-number: ${{ steps.get-comment-body.outputs.pr-number }}
63-
body: ${{ steps.get-comment-body.outputs.body }}
64-
65-
- name: Update Comment
66-
uses: peter-evans/[email protected]
67-
if: success() && steps.fc.outputs.comment-id != 0
50+
- name: Comment
51+
uses: marocchino/sticky-pull-request-comment@v2
6852
with:
69-
issue-number: ${{ steps.get-comment-body.outputs.pr-number }}
70-
body: ${{ steps.get-comment-body.outputs.body }}
71-
comment-id: ${{ steps.fc.outputs.comment-id }}
72-
edit-mode: replace
53+
header: next-bundle-analysis
54+
number: ${{ steps.get-comment-body.outputs.pr-number }}
55+
message: ${{ steps.get-comment-body.outputs.body }}

src/content/reference/react/Component.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -978,6 +978,34 @@ Defining `defaultProps` in class components is similar to using [default values]
978978

979979
---
980980

981+
### `static propTypes` {/*static-proptypes*/}
982+
983+
You can define `static propTypes` together with the [`prop-types`](https://www.npmjs.com/package/prop-types) library to declare the types of the props accepted by your component. These types will be checked during rendering and in development only.
984+
985+
```js
986+
import PropTypes from 'prop-types';
987+
988+
class Greeting extends React.Component {
989+
static propTypes = {
990+
name: PropTypes.string
991+
};
992+
993+
render() {
994+
return (
995+
<h1>Hello, {this.props.name}</h1>
996+
);
997+
}
998+
}
999+
```
1000+
1001+
<Note>
1002+
1003+
We recommend using [TypeScript](https://www.typescriptlang.org/) instead of checking prop types at runtime.
1004+
1005+
</Note>
1006+
1007+
---
1008+
9811009
### `static getDerivedStateFromError(error)` {/*static-getderivedstatefromerror*/}
9821010

9831011
If you define `static getDerivedStateFromError`, React will call it when a child component (including distant children) throws an error during rendering. This lets you display an error message instead of clearing the UI.

src/content/reference/react/useMemo.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,7 +1126,7 @@ To memoize a function with `useMemo`, your calculation function would have to re
11261126
export default function Page({ productId, referrer }) {
11271127
const handleSubmit = useMemo(() => {
11281128
return (orderDetails) => {
1129-
post('/product/' + product.id + '/buy', {
1129+
post('/product/' + productId + '/buy', {
11301130
referrer,
11311131
orderDetails
11321132
});
@@ -1142,7 +1142,7 @@ This looks clunky! **Memoizing functions is common enough that React has a built
11421142
```js {2,7}
11431143
export default function Page({ productId, referrer }) {
11441144
const handleSubmit = useCallback((orderDetails) => {
1145-
post('/product/' + product.id + '/buy', {
1145+
post('/product/' + productId + '/buy', {
11461146
referrer,
11471147
orderDetails
11481148
});

0 commit comments

Comments
 (0)