Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
27 changes: 3 additions & 24 deletions .github/workflows/analyze.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,9 @@ on:
- main # change this if your default branch is named differently
workflow_dispatch:

permissions: {}
permissions: {}

jobs:
event_type:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Save Event Type
run: echo ${{ github.event_name }} > ./event_type

- name: Upload Event Type
uses: actions/upload-artifact@v4
with:
path: ./event_type
name: event_type

analyze:
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -75,7 +61,7 @@ jobs:
if: success() && github.event.number
with:
workflow: analyze.yml
branch: ${{ github.event.pull_request.base.ref || 'main' }}
branch: ${{ github.event.pull_request.base.ref }}
name: bundle_analysis.json
path: .next/analyze/base/bundle

Expand All @@ -93,7 +79,7 @@ jobs:
# Either of these arguments can be changed or removed by editing the `nextBundleAnalysis`
# entry in your package.json file.
- name: Compare with base branch bundle
if: success()
if: success() && github.event.number
run: ls -laR .next/analyze/base && npx -p nextjs-bundle-analysis compare

- name: Upload analysis comment
Expand All @@ -102,13 +88,6 @@ jobs:
name: analysis_comment.txt
path: .next/analyze/__bundle_analysis_comment.txt

number:
runs-on: ubuntu-latest
needs: analyze
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v3

- name: Save PR number
run: echo ${{ github.event.number }} > ./pr_number

Expand Down
21 changes: 4 additions & 17 deletions .github/workflows/analyze_comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,11 @@ permissions:
jobs:
comment:
runs-on: ubuntu-latest
if: >
${{ github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Download Event Type
uses: dawidd6/action-download-artifact@v3
with:
workflow: analyze.yml
run_id: ${{ github.event.workflow_run.id }}
name: event_type
path: event_type

- name: get type
id: get-type
run: |
event_type=$(cat event_type/event_type)
echo "event-type=$event_type" >> $GITHUB_OUTPUT

- name: Download base branch bundle stats
if: github.event.workflow_run.conclusion == 'success' && steps.get-type.outputs.event-type == 'pull_request'
uses: dawidd6/action-download-artifact@268677152d06ba59fcec7a7f0b5d961b6ccd7e1e
with:
workflow: analyze.yml
Expand All @@ -39,7 +27,6 @@ jobs:
path: analysis_comment.txt

- name: Download PR number
if: github.event.workflow_run.conclusion == 'success' && steps.get-type.outputs.event-type == 'pull_request'
uses: dawidd6/action-download-artifact@268677152d06ba59fcec7a7f0b5d961b6ccd7e1e
with:
workflow: analyze.yml
Expand All @@ -49,7 +36,7 @@ jobs:

- name: Get comment body
id: get-comment-body
if: success() && github.event.workflow_run.conclusion == 'success' && steps.get-type.outputs.event-type == 'pull_request'
if: success()
run: |
echo 'body<<EOF' >> $GITHUB_OUTPUT
echo '' >> $GITHUB_OUTPUT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ React 服务器组件、资源加载、文档元数据与 Action 都已经加入

- **资源加载**:我们将 Suspense 与样式表、字体和脚本等资源的加载生命周期集成在一起,以便 React 考虑它们来确定像 [`<style>`](/reference/react-dom/components/style)、[`<link>`](/reference/react-dom/components/link) 和 [`<script>`](/reference/react-dom/components/script) 这样的元素中的内容是否已准备就绪。我们还添加了新的 [资源加载 API](/reference/react-dom#resource-preloading-apis),如 `preload` 和 `preinit`,以提供更大的控制权,指示何时应加载和初始化资源。

- **Action**:如上所述,我们已将 Action 添加到管理从客户端发送数据到服务器的功能中。现在可以将 `action` 添加到像 [`<form/>`](/reference/react-dom/components/form) 这样的元素中,使用 [`useFormStatus`](/reference/react-dom/hooks/useFormStatus) 访问状态,使用 [`useActionState`](/reference/react/useActionState) 处理结果,并使用 [`useOptimistic`](/reference/rsc/useOptimistic) 乐观地更新 UI。
- **Action**:如上所述,我们已将 Action 添加到管理从客户端发送数据到服务器的功能中。现在可以将 `action` 添加到像 [`<form/>`](/reference/react-dom/components/form) 这样的元素中,使用 [`useFormStatus`](/reference/react-dom/hooks/useFormStatus) 访问状态,使用 [`useActionState`](/reference/react/useActionState) 处理结果,并使用 [`useOptimistic`](/reference/react/useOptimistic) 乐观地更新 UI。

由于所有这些功能是相互配合的,因此单独在稳定渠道中发布它们是困难的。发布 Action 而不带有用于访问表单状态的补充 Hook 会限制 Action 的实际可用性。引入 React 服务器组件而不集成 Server Action 会把在服务器上修改数据变得复杂化。

Expand Down
4 changes: 2 additions & 2 deletions src/content/blog/2024/12/05/react-19.md
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ React 19 包含了所有从 Canary 渠道引入的 React 服务器组件功能

有关更多信息,请参阅文档 [React Server Components](/reference/rsc/server-components).

### 服务器操作 {/*server-actions*/}
### 服务器操作 {/*server-functions*/}

服务器 Actions 允许客户端组件调用在服务器上执行的异步函数。

Expand All @@ -389,7 +389,7 @@ React 19 包含了所有从 Canary 渠道引入的 React 服务器组件功能

服务器 Actions 可以在服务器组件中创建并作为 props 传递给客户端组件,或者可以在客户端组件中导入和使用。

有关更多信息,请参阅 [React 服务器 Actions](/reference/rsc/server-actions) 文档。
有关更多信息,请参阅 [React 服务器 Actions](/reference/rsc/server-functions) 文档。

## React 19 中的改进 {/*improvements-in-react-19*/}

Expand Down
Loading
Loading