Skip to content

Rule to forbid calling components as functions? #3208

Closed as not planned
Closed as not planned
@FezVrasta

Description

@FezVrasta

Sometimes inexperienced developers define functions that return jsx that would better work as components.

example:

const App = () => {
  function renderIcon() {
    return <i />;
  }
  
  return (
    <div>{renderIcon()}</div>
  );
}

I’d like a rule to forbid this behavior and instead suggest to convert it to a proper competent called with jsx.

this allows React to optimize its re-renders.

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