|
1
|
export const metadata = { |
|
2
|
title: `${pageNumber} Admin Development Constraints`, |
|
3
|
} |
|
4
|
|
|
5
|
# {metadata.title} |
|
6
|
|
|
7
|
This chapter lists some development constraints of admin widgets and UI routes. |
|
8
|
|
|
9
|
## Arrow Functions |
|
10
|
|
|
11
|
Widget and UI route components must be created as arrow functions. Otherwise, Medusa doesn't register them correctly. |
|
12
|
|
|
13
|
export const arrowHighlights = [ |
|
14
|
["2", "function", "Don't declare the widget / UI route as a function."], |
|
15
|
["7", "() => ", "Use arrow functions when creating a widget / UI route."] |
|
16
|
] |
|
17
|
|
|
18
|
```ts highlights={arrowHighlights} |
|
19
|
// Don't |
|
20
|
function ProductWidget() { |
|
21
|
// ... |
|
22
|
} |
|
23
|
|
|
24
|
// Do |
|
25
|
const ProductWidget = () => { |
|
26
|
// ... |
|
27
|
} |
|
28
|
``` |
|
29
|
|
|
30
|
--- |
|
31
|
|
|
32
|
## Widget Zone |
|
33
|
|
|
34
|
A widget zone's value must be wrapped in double or single quotes. It can't be a template literal or a variable. Otherwise, Medusa doesn't register the widget correctly. |
|
35
|
|
|
36
|
export const zoneHighlights = [ |
|
37
|
["3", "`product.details`", "Don't specify the value of `zone` as a template literal."], |
|
38
|
["9", "ZONE", "Don't specify a variable as the value of `zone`."], |
|
39
|
["14", `"product.details"`, "Wrap the value of `zone` in double or single quotes."] |
|
40
|
] |
|
41
|
|
|
42
|
```ts highlights={zoneHighlights} |
|
43
|
// Don't |
|
44
|
export const config = defineWidgetConfig({ |
|
45
|
zone: `product.details`, |
|
46
|
}) |
|
47
|
|
|
48
|
// Don't |
|
49
|
const ZONE = "product.details" |
|
50
|
export const config = defineWidgetConfig({ |
|
51
|
zone: ZONE, |
|
52
|
}) |
|
53
|
|
|
54
|
// Do |
|
55
|
export const config = defineWidgetConfig({ |
|
56
|
zone: "product.details", |
|
57
|
}) |
|
58
|
``` |