Skip to content

Question about "calling an impure function can produce unstable results..." lint #34048

@controversial

Description

@controversial

What kind of issue is this?

  • React Compiler core (the JS output is incorrect, or your app works incorrectly after optimization)
  • babel-plugin-react-compiler (build issue installing or using the Babel plugin)
  • eslint-plugin-react-compiler (build issue installing or using the eslint plugin)
  • react-compiler-healthcheck (build issue installing or using the healthcheck script)

Link to repro

https://playground.react.dev/#N4Igzg9grgTgxgUxALhASwLYAcIwC4AEwBUYCAsghhAQL4EBmMEGBA5DAgIZx5sDcAHQB2IhAA8c+AgBMEDLlAA2hBlGG80EYQXIBPAIJYsACgCUREQQJxtYQva74AKpgQEAvCTKVqJ854AfARYCDAMuBhcGggAdMIQAO7mZkLCtCIgtEA

Repro steps

Run eslint-plugin-react-hooks with the react-compiler rule enabled

export default function MyApp() {
  const startTime = useMemo(() => performance.now());
}

The error says

Calling an impure function can produce unstable results that update unpredictably when the component happens to re-render

I’m not sure what the right way to record this type of state is now, because react-compiler also rejects anything of the form

  const [startTime, setStartTime] = useState(null);
  useEffect(() => { setStartTime(performance.now()); }, []);

for “calling setState synchronously within an effect body.”

How often does this bug happen?

Every time

What version of React are you using?

react@19.1.1

What version of React Compiler are you using?

eslint-plugin-react-hooks@0.0.0-experimental-97cdd5d3-20250710

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions