---
url: /docs/guide/usage/linter/rules/react/purity.md
---

### What it does

Validates that components and hooks are pure by checking that they do
not call known-impure functions such as `Math.random()`, `Date.now()`,
or `performance.now()` during render.

Powered by the React Compiler, which runs once per file and is shared
with the other React Compiler rules. Port of
[`react-hooks/purity`](https://react.dev/reference/eslint-plugin-react-hooks/lints/purity).

### Why is this bad?

Impure renders return different output for the same props and state,
breaking memoization, concurrent rendering, and replayability.

### Examples

Examples of **incorrect** code for this rule:

```jsx
function Component() {
  const rand = Math.random();
  return <div>{rand}</div>;
}
```

Examples of **correct** code for this rule:

```jsx
import { useState } from "react";
function Component() {
  const [rand, setRand] = useState(0);
  return <button onClick={() => setRand(Math.random())}>{rand}</button>;
}
```

## How to use

## Version

This rule was added in v1.79.0.

## References
