Skip to content

Commit 5d0fa9b

Browse files
committed
Remove Belt from array-and-keys.mdx
1 parent e6837b5 commit 5d0fa9b

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

bun.lockb

423 KB
Binary file not shown.

pages/docs/react/latest/arrays-and-keys.mdx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ Keys help React identify which elements have been changed, added, or removed thr
1919
```res
2020
let numbers = [1, 2, 3, 4, 5];
2121
22-
let items = Belt.Array.map(numbers, (number) => {
23-
<li key={Belt.Int.toString(number)}> {React.int(number)} </li>
22+
let items = Array.map(numbers, (number) => {
23+
<li key={Int.toString(number)}> {React.int(number)} </li>
2424
})
2525
```
2626

@@ -34,17 +34,17 @@ let todos = [
3434
{id: "todo2", text: "Todo 2"}
3535
]
3636
37-
let items = Belt.Array.map(todos, todo => {
37+
let items = Array.map(todos, todo => {
3838
<li key={todo.id}> {React.string(todo.text)} </li>
3939
})
4040
```
4141

4242
If you don’t have stable IDs for rendered items, you may use the item index as a key as a last resort:
4343

4444
```res {1..3}
45-
let items = Belt.Array.mapWithIndex(todos, (i, todo) => {
45+
let items = Array.mapWithIndex(todos, (i, todo) => {
4646
// Only do this if items have no stable id
47-
<li key={Belt.Int.toString(i)}>
47+
<li key={Int.toString(i)}>
4848
{todo.text}
4949
</li>
5050
});
@@ -63,15 +63,15 @@ module Blog = {
6363
let sidebar =
6464
<ul>
6565
{
66-
Belt.Array.map(posts, (post) => {
66+
Array.map(posts, (post) => {
6767
<li key={post.id}>
6868
{React.string(post.title)}
6969
</li>
7070
})->React.array
7171
}
7272
</ul>
7373
74-
let content = Belt.Array.map(posts, (post) => {
74+
let content = Array.map(posts, (post) => {
7575
<div key={post.id}>
7676
<h3>{React.string(post.title)}</h3>
7777
<p>{React.string(post.content)}</p>
@@ -111,8 +111,8 @@ let make = () => {
111111
112112
let items =
113113
todoList
114-
->Belt.List.toArray
115-
->Belt.Array.map(todo => {
114+
->List.toArray
115+
->Array.map(todo => {
116116
<li key={todo.id}> {React.string(todo.text)} </li>
117117
})
118118
@@ -121,7 +121,7 @@ let make = () => {
121121
122122
```
123123

124-
We use `Belt.List.toArray` to convert our list to an array before creating our `array<React.element>`. Please note that using `list` has performance impact due to extra conversion costs.
124+
We use `List.toArray` to convert our list to an array before creating our `array<React.element>`. Please note that using `list` has performance impact due to extra conversion costs.
125125

126126
99% of the time you'll want to use arrays (seamless interop, faster JS code), but in some cases it might make sense to use a `list` to leverage advanced pattern matching features etc.
127127

0 commit comments

Comments
 (0)