Skip to content
← Back to rules

react/capitalized-calls Suspicious

What it does

Disallows calling capitalized functions or methods directly during render instead of rendering them with JSX, since capitalized names are reserved for components.

Powered by the React Compiler, which runs once per file and is shared with the other React Compiler rules. Port of react-hooks/capitalized-calls.

Why is this bad?

Calling a component as a plain function hides it from React: it gets no state isolation and no hooks context of its own, and it breaks memoization.

Examples

Examples of incorrect code for this rule:

jsx
import Child from "./Child";
function Component() {
  return <div>{Child()}</div>;
}

Examples of correct code for this rule:

jsx
import Child from "./Child";
function Component() {
  return (
    <div>
      <Child />
    </div>
  );
}

How to use

To enable this rule using the config file or in the CLI, you can use:

json
{
  "plugins": ["react"],
  "rules": {
    "react/capitalized-calls": "error"
  }
}
ts
import { defineConfig } from "oxlint";

export default defineConfig({
  plugins: ["react"],
  rules: {
    "react/capitalized-calls": "error",
  },
});
bash
oxlint --deny react/capitalized-calls --react-plugin

Version

This rule was added in vnext.

References