noVueSetupPropsReactivityLoss
Esta página aún no está disponible en tu idioma.
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`.
ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.
export default { setup(props) { return () => h('div', props.count); }}Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.