Title: Request order changes the component's content / 请求顺序改变了组件的内容 · Issue #773 · voidzero-dev/void · GitHub
Open Graph Title: Request order changes the component's content / 请求顺序改变了组件的内容 · Issue #773 · voidzero-dev/void
X Title: Request order changes the component's content / 请求顺序改变了组件的内容 · Issue #773 · voidzero-dev/void
Description: Problem With a type-only defineProps
Open Graph Description: Problem With a type-only defineProps
X Description: Problem With a type-only defineProps<T>() page component in @void/vue, the component's props are fixed by the first request that renders it in a process. If a later request's loader r...
Opengraph URL: https://github.com/voidzero-dev/void/issues/773
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Request order changes the component's content / 请求顺序改变了组件的内容","articleBody":"## Problem\n\nWith a type-only `defineProps\u003cT>()` page component in `@void/vue`, the component's props are fixed by the first request that renders it in a process. If a later request's loader returns a key the first request did not return, that key is not passed as a prop; Vue renders it as an HTML attribute on the root element.\n\nVersions: `void@1.7.0`, `@void/vue@1.7.0`.\n\n## Reproduction\n\nhttps://gist.github.com/wintercn/5a21b099a048602b1c4561c703faba25\n\nThe loader of `/items/:id` returns `{ title: 'A' }` for `a` and `{ title: 'B', note: 'N' }` for `b`. File layout and commands are in the gist's `README.md`.\n\nFresh preview process, request `/items/a`, `/items/b`, `/items/b`:\n\n```\n/items/a \u003cdiv>\u003ch1>A\u003c/h1>\u003cp>note=\u003c/p>\u003c/div>\n/items/b \u003cdiv note=\"N\">\u003ch1>B\u003c/h1>\u003cp>note=\u003c/p>\u003c/div>\n/items/b \u003cdiv note=\"N\">\u003ch1>B\u003c/h1>\u003cp>note=\u003c/p>\u003c/div>\n```\n\nFresh preview process, request `/items/b`, `/items/a`, `/items/b`:\n\n```\n/items/b \u003cdiv>\u003ch1>B\u003c/h1>\u003cp>note=N\u003c/p>\u003c/div>\n/items/a \u003cdiv>\u003ch1>A\u003c/h1>\u003cp>note=\u003c/p>\u003c/div>\n/items/b \u003cdiv>\u003ch1>B\u003c/h1>\u003cp>note=N\u003c/p>\u003c/div>\n```\n\nAll responses are `200` with no error in the log.\n\n## Expected\n\n`/items/b` renders `\u003cdiv>\u003ch1>B\u003c/h1>\u003cp>note=N\u003c/p>\u003c/div>` regardless of request order.\n\n## Related\n\n#557 listed \"Do not derive a permanent props declaration from the first received props object\". #589 fixed only components with a runtime props declaration.\n\n## Analysis\n\n`@void/vue` strips the type argument of `defineProps\u003cT>()`, so the component has no runtime props. `patchProps` then sets `comp.props = Object.keys(props)` from the first page data and marks `__voidPatched`, so later keys are never declared.\n\n---\n\n## 问题\n\n`@void/vue` 中,页面组件只用类型参数声明 props(`defineProps\u003cT>()`)时,props 由进程里第一个渲染它的请求固定。之后的请求如果 loader 返回了第一次没有的字段,这个字段不会作为 prop 传入,而是被渲染成根元素上的 HTML 属性。\n\n## 复现\n\nhttps://gist.github.com/wintercn/5a21b099a048602b1c4561c703faba25\n\n`/items/:id` 的 loader 对 `a` 返回 `{ title: 'A' }`,对 `b` 返回 `{ title: 'B', note: 'N' }`。文件布局和命令见 gist 的 `README.md`。\n\n新预览进程,依次请求 `/items/a`、`/items/b`、`/items/b`:\n\n```\n/items/a \u003cdiv>\u003ch1>A\u003c/h1>\u003cp>note=\u003c/p>\u003c/div>\n/items/b \u003cdiv note=\"N\">\u003ch1>B\u003c/h1>\u003cp>note=\u003c/p>\u003c/div>\n/items/b \u003cdiv note=\"N\">\u003ch1>B\u003c/h1>\u003cp>note=\u003c/p>\u003c/div>\n```\n\n新预览进程,依次请求 `/items/b`、`/items/a`、`/items/b`:\n\n```\n/items/b \u003cdiv>\u003ch1>B\u003c/h1>\u003cp>note=N\u003c/p>\u003c/div>\n/items/a \u003cdiv>\u003ch1>A\u003c/h1>\u003cp>note=\u003c/p>\u003c/div>\n/items/b \u003cdiv>\u003ch1>B\u003c/h1>\u003cp>note=N\u003c/p>\u003c/div>\n```\n\n所有响应都是 `200`,日志没有错误。\n\n## 预期\n\n不论请求顺序,`/items/b` 都渲染为 `\u003cdiv>\u003ch1>B\u003c/h1>\u003cp>note=N\u003c/p>\u003c/div>`。\n\n## 分析\n\n`@void/vue` 去掉了 `defineProps\u003cT>()` 的类型参数,组件没有运行时 props。`patchProps` 用第一次的页面数据设置 `comp.props = Object.keys(props)` 并标记 `__voidPatched`,后来新增的字段不会再被声明。\n","author":{"url":"https://github.com/wintercn","@type":"Person","name":"wintercn"},"datePublished":"2026-11-10T16:07:24Z","url":"https://github.com/voidzero-dev/void/issues/773"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:a2019e7d-b5e7-1cb1-c311-08ab36fe3022 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C67A:1BD5CA:1BC1338:25BBC1E:6AFB92AE |
| html-safe-nonce | 308a540622b19ab6468e93fde4a12e86b6e5178deb514564cf83515e047d6208 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNjdBOjFCRDVDQToxQkMxMzM4OjI1QkJDMUU6NkFGQjkyQUUiLCJ2aXNpdG9yX2lkIjoiMjg4NDM0MTQ5MzM2NTcwNzQzOCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 51ca746a5d818e49e185dd32705aafd3e94f03e72859b068358b25f151e5ed44 |
| hovercard-subject-tag | issue:6310748194 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/voidzero-dev/void/773/issue_layout |
| twitter:image | https://opengraph.githubassets.com/575f2c5909cb372eb722735be106725e14ecaace439b3ae12140ecf559d02e32/voidzero-dev/void/issues/773 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/575f2c5909cb372eb722735be106725e14ecaace439b3ae12140ecf559d02e32/voidzero-dev/void/issues/773 |
| og:image:alt | Problem With a type-only defineProps |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | wintercn |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4f01efe06174a5ba6342fd58e42d02295e0675bedbb465d6bef2dbaec8e46556 |
| turbo-cache-control | no-preview |
| go-import | github.com/voidzero-dev/void git https://github.com/voidzero-dev/void.git |
| octolytics-dimension-user_id | 149750581 |
| octolytics-dimension-user_login | voidzero-dev |
| octolytics-dimension-repository_id | 1164437080 |
| octolytics-dimension-repository_nwo | voidzero-dev/void |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1164437080 |
| octolytics-dimension-repository_network_root_nwo | voidzero-dev/void |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | a52db8866b6543b4e83730cd6a6b1360f1a9e4dc |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width