Skip to content
Critiq Docs

Search docs

Search documentation pages and rules

correctness.ui

Do not use this in function components

Function components have no instance, so `this` references are almost always mistakes copied from class components.

#Metadata

Rule ID
ts.react.no-this-in-function-component
Severity
high
Confidence
0.76
Languages
javascript, typescript
Presets
recommended, strict
Stability
experimental
Applies to
function
Tags
react, rules-catalog, ui

#Why it matters

Hooks, props, and closures replace instance fields; leaving `this` in place breaks at runtime or hides missing refactors.

#Remediation

Use props, hooks, module-level helpers, or refs instead of instance fields accessed through this.

#Repository path

The generated metadata points to critiq-rules/libs/rules/catalog/rules/typescript/ts.react.no-this-in-function-component.rule.yaml.