1 ---
2 sidebar_label: "admin-component-must-be-arrow-function"
3 ---
4
5 export const metadata = {
6 title: `admin-component-must-be-arrow-function - ESLint plugin rules`,
7 }
8
9 # {metadata.title}
10
11 This rule requires admin widget and UI route components to be arrow functions, not function declarations.
12
13 ## Severity
14
15 `error`. This rule is enabled in the [recommended](../../page.mdx#recommended) preset.
16
17 ## What it Targets
18
19 This rule targets files in your project's `src/admin/widgets` directory and `page.tsx` files in your project's `src/admin/routes` directory. It reports a default-exported component that's declared as a function declaration.
20
21 The following code is reported by the rule:
22
23 ```tsx title="src/admin/widgets/product-widget.tsx"
24 export default function MyWidget() {
25 return null
26 }
27 ```
28
29 Instead, declare the component as an arrow function:
30
31 ```tsx title="src/admin/widgets/product-widget.tsx"
32 const MyWidget = () => {
33 return null
34 }
35
36 export default MyWidget
37 ```
38
39 ## Why it's Important
40
41 Medusa only picks up admin widget and UI route components declared as arrow functions. Declaring them as function declarations causes them not to be registered, which can lead to runtime errors.
42
43 Learn more in the [Admin Development Constraints documentation](!docs!/learn/fundamentals/admin/constraints).
44
45 ## Fixable
46
47 This rule is auto-fixable. Run the linter with the `--fix` option to apply the fix automatically.