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
Rename the temp example source from _tempFile to Example so derived JS output no longer leaks the temp filename.
Refresh the JSX preserved-output docs that are in scope for the new three-tab ReScript CodeTab flow.
let items =todos.map((todo) =><li key={todo.id}>{todo.text}</li>);
86
+
return<ul>{items}</ul>;
87
+
}
88
+
89
+
let make = Example;
67
90
68
91
export { make };
69
92
```
@@ -74,7 +97,7 @@ export { make };
74
97
75
98
Keys help React identify which elements have been changed, added, or removed throughout each render. Keys should be given to elements inside the array to give the elements a stable identity:
@@ -102,6 +125,16 @@ let items = numbers.map((number) =>
102
125
export { numbers, items };
103
126
```
104
127
128
+
```jsx
129
+
import*asJsxRuntimefrom"react/jsx-runtime";
130
+
131
+
let numbers = [1, 2, 3, 4, 5];
132
+
133
+
let items =numbers.map((number) =><li key={number.toString()}>{number}</li>);
134
+
135
+
export { numbers, items };
136
+
```
137
+
105
138
</CodeTab>
106
139
107
140
The best way to pick a key is to use a string that uniquely identifies a list item among its siblings. Most often you would use IDs from your data as keys:
@@ -148,7 +181,7 @@ var items = todos.map(function (todo) {
148
181
149
182
If you don’t have stable IDs for rendered items, you may use the item index as a key as a last resort:
let items =todos.map((todo, i) =><li key={i.toString()}>{todo.text}</li>);
249
+
250
+
export { todos, items };
251
+
```
252
+
199
253
</CodeTab>
200
254
201
255
### Keys Must Only Be Unique Among Siblings
202
256
203
257
Keys used within arrays should be unique among their siblings. However they don’t need to be globally unique. We can use the same keys when we produce two different arrays:
0 commit comments