Skip to content

Commit

Permalink
Merge pull request reactjs#857 from reactjs/sync-7ea43a8d
Browse files Browse the repository at this point in the history
Sync with react.dev @ 7ea43a8
  • Loading branch information
gaearon authored Apr 28, 2023
2 parents 62cd321 + 40a7976 commit 6257641
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/analyze.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
# Here's the first place where next-bundle-analysis' own script is used
# This step pulls the raw bundle stats for the current bundle
- name: Analyze bundle
run: npx -p nextjs-bundle-analysis report
run: npx -p nextjs-bundle-analysis@0.5.0 report

- name: Upload bundle
uses: actions/upload-artifact@v2
Expand Down
27 changes: 5 additions & 22 deletions .github/workflows/analyze_comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,26 +47,9 @@ jobs:
pr_number=$(cat pr_number/pr_number)
echo "pr-number=$pr_number" >> $GITHUB_OUTPUT
- name: Find Comment
uses: peter-evans/find-comment@v1
if: success()
id: fc
with:
issue-number: ${{ steps.get-comment-body.outputs.pr-number }}
body-includes: "<!-- __NEXTJS_BUNDLE -->"

- name: Create Comment
uses: peter-evans/[email protected]
if: success() && steps.fc.outputs.comment-id == 0
with:
issue-number: ${{ steps.get-comment-body.outputs.pr-number }}
body: ${{ steps.get-comment-body.outputs.body }}

- name: Update Comment
uses: peter-evans/[email protected]
if: success() && steps.fc.outputs.comment-id != 0
- name: Comment
uses: marocchino/sticky-pull-request-comment@v2
with:
issue-number: ${{ steps.get-comment-body.outputs.pr-number }}
body: ${{ steps.get-comment-body.outputs.body }}
comment-id: ${{ steps.fc.outputs.comment-id }}
edit-mode: replace
header: next-bundle-analysis
number: ${{ steps.get-comment-body.outputs.pr-number }}
message: ${{ steps.get-comment-body.outputs.body }}
28 changes: 28 additions & 0 deletions src/content/reference/react/Component.md
Original file line number Diff line number Diff line change
Expand Up @@ -978,6 +978,34 @@ Defining `defaultProps` in class components is similar to using [default values]

---

### `static propTypes` {/*static-proptypes*/}

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.

```js
import PropTypes from 'prop-types';
class Greeting extends React.Component {
static propTypes = {
name: PropTypes.string
};
render() {
return (
<h1>Hello, {this.props.name}</h1>
);
}
}
```

<Note>

We recommend using [TypeScript](https://www.typescriptlang.org/) instead of checking prop types at runtime.

</Note>

---

### `static getDerivedStateFromError(error)` {/*static-getderivedstatefromerror*/}

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.
Expand Down
4 changes: 2 additions & 2 deletions src/content/reference/react/useMemo.md
Original file line number Diff line number Diff line change
Expand Up @@ -1126,7 +1126,7 @@ To memoize a function with `useMemo`, your calculation function would have to re
export default function Page({ productId, referrer }) {
const handleSubmit = useMemo(() => {
return (orderDetails) => {
post('/product/' + product.id + '/buy', {
post('/product/' + productId + '/buy', {
referrer,
orderDetails
});
Expand All @@ -1142,7 +1142,7 @@ This looks clunky! **Memoizing functions is common enough that React has a built
```js {2,7}
export default function Page({ productId, referrer }) {
const handleSubmit = useCallback((orderDetails) => {
post('/product/' + product.id + '/buy', {
post('/product/' + productId + '/buy', {
referrer,
orderDetails
});
Expand Down

0 comments on commit 6257641

Please sign in to comment.