Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Aug 5, 2024. It is now read-only.

Commit 731fde6

Browse files
committed
Repeated bricks with index example
1 parent e3aa537 commit 731fde6

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

pages/docs/nested-blocks/repeated-bricks.mdx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,18 @@ description: A brick used as repeater item must spread rest props on root elemen
77

88
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.
99

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+
1012
## Example
1113

1214
```tsx highlight=5
1315
const Badge: types.Brick<BadgeProps> = ({
16+
index,
1417
...rest
1518
}) => {
1619
return (
1720
<div {...rest}>
21+
I am the item #{index}.
1822
...
1923
</div>
2024
)
@@ -26,5 +30,3 @@ Badge.schema = {
2630

2731
export default Badge
2832
```
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

Comments
 (0)