JSX attributes

@once

Edit this page

/*@once*/ is a compiler marker comment that marks a JSX expression as static.


Syntax

<MyComponent value={/*@once*/ expr} />

Behavior

  • /*@once*/ applies to the expression that follows it.
  • Marked expressions are compiled as static and do not update when reactive dependencies change.
  • It can be used in props and in children.
  • Some compiler transforms, including parts of classList and style handling, do not fully respect /*@once*/.

Examples

Prop value

<MyComponent static={/*@once*/ state.wontUpdate} />

Child value

<MyComponent>{/*@once*/ state.wontUpdate}</MyComponent>
Report an issue with this page