useQwikClasslist
Ta treść nie jest jeszcze dostępna w Twoim języku.
Summary
Section titled “Summary”- Rule available since:
v2.1.4 - Diagnostic Category:
lint/correctness/useQwikClasslist - This rule doesn’t have a fix.
- The default severity of this rule is error.
- This rule belongs to the following domains:
- Sources:
- Same as
qwik/prefer-classlist
- Same as
How to configure
Section titled “How to configure”{ "linter": { "rules": { "correctness": { "useQwikClasslist": "error" } } }}Description
Section titled “Description”Prefer using the class prop as a classlist over the classnames helper.
This rule encourages the use of class prop which natively supports strings, objects, and arrays, enabling fine-grained reactivity and optimal performance. Using utilities like classnames can interfere with Qwik’s reactivity model and prevent the framework from optimizing component updates. Prefer using the built-in class prop for best results.
For more information, see: Qwik documentation on class bindings
Examples
Section titled “Examples”Invalid
Section titled “Invalid”<div class={classnames({ active: true, disabled: false })} />code-block.jsx:1:6 lint/correctness/useQwikClasslist ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Avoid third-party classnames utilities with Qwik components
> 1 │ <div class={classnames({ active: true, disabled: false })} />
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 │
ℹ Qwik’s built-in class prop handles:
- Conditional classes via objects: class={{ active: isActive }}
- Dynamic string concatenation
- Array combinations
External utilities break Qwik’s:
- Fine-grained reactivity tracking
- Resumability optimizations
ℹ Use native Qwik class binding as shown in Qwik Rendering: Class Bindings (Official Docs).
<div class={{ active: true, disabled: false }} />Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.