docs: add v4.4 badge for layout props#34528
Conversation
|
|
587f50a to
9fdefc9
Compare
WalkthroughA documentation change was made to the Nuxt directory-structure layouts page: the "Passing Props to Layouts" section heading was updated to include a version badge for 4.4. No other content, functional code, or exported/public declarations were modified; the change is a single-line edit to the documentation file that adds version context to the heading. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
docs/2.directory-structure/1.app/1.layouts.md (1)
173-219: Mention thatlayoutPropsvalues must be serialisable.This section currently reads as if any prop object will work, but the runtime stores
layoutPropson route meta / payload state. A short note here would help users avoid passing refs, functions, or class instances that will not survive SSR/hydration cleanly.✏️ Suggested wording
You can pass props to a layout by providing a `layoutProps` object in [`definePageMeta`](/docs/4.x/api/utils/define-page-meta): + +`layoutProps` should only contain serialisable values.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@docs/2.directory-structure/1.app/1.layouts.md` around lines 173 - 219, Add a short note explaining that layoutProps (as used with definePageMeta and when passing props via setPageLayout) must be serialisable because they are stored on the route meta/payload and survive SSR/hydration; explicitly warn authors not to pass refs, functions, or class instances (use plain JSON-serialisable values) and insert this sentence near the examples that demonstrate layoutProps and the admin NuxtLayouts declaration so users see the restriction before the admin.vue layout example.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/nuxt/src/app/composables/asyncData.ts`:
- Around line 843-859: On the branch where purgeCachedData &&
!hasCustomGetCachedData is true, eagerly clear nuxtApp.payload.data[key] and
nuxtApp.payload._errors?.[key] before deferring the silent dispose to nextTick
to avoid a same-flush recreation reusing stale payload or error; keep the
deferred call to nextTick(() => { if (!nuxtApp._asyncData[key]?._init)
clearNuxtDataByKey(nuxtApp, key, { silent: true }) }) and the existing
_preserveOnInit logic, but move the payload and _errors deletion to run
immediately when deciding not to preserve (i.e., in the else branch before
nextTick) so new createAsyncData/useNuxtData instances cannot inherit old data
or errors.
---
Nitpick comments:
In `@docs/2.directory-structure/1.app/1.layouts.md`:
- Around line 173-219: Add a short note explaining that layoutProps (as used
with definePageMeta and when passing props via setPageLayout) must be
serialisable because they are stored on the route meta/payload and survive
SSR/hydration; explicitly warn authors not to pass refs, functions, or class
instances (use plain JSON-serialisable values) and insert this sentence near the
examples that demonstrate layoutProps and the admin NuxtLayouts declaration so
users see the restriction before the admin.vue layout example.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 53a0a369-1205-4fcc-8e66-4eed9352bd1d
📒 Files selected for processing (5)
docs/2.directory-structure/1.app/1.layouts.mddocs/4.api/3.utils/set-page-layout.mdpackages/nuxt/src/app/composables/asyncData.tspackages/nuxt/src/app/nuxt.tstest/nuxt/use-async-data.test.ts
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
docs/2.directory-structure/1.app/1.layouts.md (1)
177-228: Consider documenting thelayoutPropsfield for pre-4.4 compatibility.According to issue
#34527, whilst the object syntax (layout: { name, props }) requires v4.4, thelayoutPropsfield works in earlier versions:definePageMeta({ layout: 'panel', layoutProps: { sidebar: true, title: 'Dashboard' } })Users on versions before 4.4 would benefit from having this alternative documented, perhaps in a note or a separate subsection. Additionally, verify whether
setPageLayoutwith props (line 227) also requires v4.4, and if so, add a corresponding version indicator.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@docs/2.directory-structure/1.app/1.layouts.md` around lines 177 - 228, Add documentation for the pre-4.4 compatibility field by describing the layoutProps alternative and showing its usage (e.g., in definePageMeta use layout: 'panel' plus layoutProps: { sidebar: true, title: 'Dashboard' }); include a short note or subsection explaining that the object syntax layout: { name, props } requires v4.4 while layoutProps works in earlier versions, and update the setPageLayout mention to indicate whether passing props via setPageLayout(...) requires v4.4 (verify implementation of setPageLayout and add a version indicator next to its example if it does).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@docs/2.directory-structure/1.app/1.layouts.md`:
- Line 171: The version badge on the "Passing Props to Layouts" heading is
incorrect—change the badge token :badge[+4.4]{color="info" class="align-middle"}
to :badge[+4.3]{color="info" class="align-middle"} (or :badge[+4.3.0]{...}) so
the header "## Passing Props to Layouts :badge[+4.4]{...}" correctly reflects
the feature shipping in Nuxt v4.3.0.
---
Nitpick comments:
In `@docs/2.directory-structure/1.app/1.layouts.md`:
- Around line 177-228: Add documentation for the pre-4.4 compatibility field by
describing the layoutProps alternative and showing its usage (e.g., in
definePageMeta use layout: 'panel' plus layoutProps: { sidebar: true, title:
'Dashboard' }); include a short note or subsection explaining that the object
syntax layout: { name, props } requires v4.4 while layoutProps works in earlier
versions, and update the setPageLayout mention to indicate whether passing props
via setPageLayout(...) requires v4.4 (verify implementation of setPageLayout and
add a version indicator next to its example if it does).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: fed4476f-d152-4f23-905f-da9ca308eaa6
📒 Files selected for processing (1)
docs/2.directory-structure/1.app/1.layouts.md
9fdefc9 to
4b88652
Compare
closes #34527