Back to all reviewers

Use React.FC consistently

vadimdemedes/ink
Based on 2 comments
TSX

Use React.FC (or React.FunctionComponent) for typing functional components instead of verbose function type definitions. React.FC provides built-in typing for common props like children, key, and ref, reducing boilerplate and ensuring consistency across the codebase.

React TSX

Reviewer Prompt

Use React.FC (or React.FunctionComponent) for typing functional components instead of verbose function type definitions. React.FC provides built-in typing for common props like children, key, and ref, reducing boilerplate and ensuring consistency across the codebase.

Instead of verbose function signatures:

const UserInput: (props: { test: string }) => JSX.Element | null = ({test}) => {
  // component logic
};

Use React.FC for cleaner, more maintainable type definitions:

const UserInput: React.FC<{ test: string }> = ({test}) => {
  // component logic
};

When children are required (not optional), include them explicitly in your props interface rather than relying on React.FC’s optional children:

interface ColorProps {
  color: string;
  children: ReactNode; // explicit when required
}

const Color: React.FC<ColorProps> = ({color, children}) => {
  // component logic
};

This approach provides better TypeScript integration, clearer component contracts, and leverages React’s built-in type definitions effectively.

2
Comments Analyzed
TSX
Primary Language
React
Category

Source Discussions