noVueSetupPropsReactivityLoss
Цей контент ще не доступний вашою мовою.
Summary
Section titled “Summary”- Rule available since:
v2.2.6 - Diagnostic Category:
lint/nursery/noVueSetupPropsReactivityLoss - This rule doesn’t have a fix.
- The default severity of this rule is information.
- This rule belongs to the following domains:
- Sources:
- Inspired from
vue/no-setup-props-reactivity-loss
- Inspired from
How to configure
Section titled “How to configure”{ "linter": { "rules": { "nursery": { "noVueSetupPropsReactivityLoss": "error" } } }}Description
Section titled “Description”Disallow destructuring of props passed to setup in Vue projects.
In Vue’s Composition API, props must be accessed as props.propertyName to maintain
reactivity. Destructuring props directly in the setup function parameters will
cause the resulting variables to lose their reactive nature.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”export default { setup({ count }) { return () => h('div', count); }}code-block.js:2:9 lint/nursery/noVueSetupPropsReactivityLoss ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ Destructuring `props` in the `setup` function parameters loses reactivity.
1 │ export default {
> 2 │ setup({ count }) {
│ ^^^^^^^^^
3 │ return () => h(‘div’, count);
4 │ }
ℹ To preserve reactivity, access props as properties: `props.propertyName`.
export default { setup(props) { return () => h('div', props.count); }}Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.