-
-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Description
Would it be possible to ignore React components in the rule where? While I agree that function declaration is preferable when exporting a function (i.e. export function somefn() { /* ... */}), I would like to make exception for React components, because arrow functions are typed more easily.
When using function declaration, you have to type props and also return (from my experience, people usually forget to add null):
interface BoldProps {
caption: string;
}
export function Bold({ caption }: BoldProps): JSX.Element | null {
return <b>{caption}</b>;
}Using arrow function is little bit more concise, less error prone, but still readable thanks to the React.FC type right after the variable name:
interface BoldProps {
caption: string;
}
export const Bold: React.FC<BoldProps> = ({ caption }) => {
return <b>{caption}</b>;
}Thanks for the info.
Metadata
Metadata
Assignees
Labels
No labels