Pular para o conteúdo

noVueSetupPropsReactivityLoss

Este conteúdo não está disponível em sua língua ainda.

biome.json
{
"linter": {
"rules": {
"nursery": {
"noVueSetupPropsReactivityLoss": "error"
}
}
}
}

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.

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);
}
}