You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 5, 2024. It is now read-only.
Copy file name to clipboardExpand all lines: pages/docs/nested-blocks/repeated-bricks.mdx
+4-2Lines changed: 4 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,14 +7,18 @@ description: A brick used as repeater item must spread rest props on root elemen
7
7
8
8
A brick used as a repeater item is just a normal brick, but it must spread `...rest` props on its root element in order to be correctly focusable in the Admin interface.
9
9
10
+
A repeated bricks receives also the `index` on the props, so that it may conditionally render based on its position in the items array.
11
+
10
12
## Example
11
13
12
14
```tsx highlight=5
13
15
const Badge:types.Brick<BadgeProps> = ({
16
+
index,
14
17
...rest
15
18
}) => {
16
19
return (
17
20
<div{...rest}>
21
+
I am the item #{index}.
18
22
...
19
23
</div>
20
24
)
@@ -26,5 +30,3 @@ Badge.schema = {
26
30
27
31
exportdefaultBadge
28
32
```
29
-
30
-
A repeated bricks receives also the `index` on the props, so that it may conditionally render based on its position in the items array.
0 commit comments