Skip to content

Commit e812610

Browse files
committed
Remove deprecated loremflickr placeholder images
The previous examples used a service called loremflickr.com to link to placeholder images. Since that service is now down, I updated them to reference placecats.com instead, which we already use in other examples as well. placecats doesn't have the same random cat feature so I roughly approximated it in the example code. Closes #7966
1 parent ff11cd2 commit e812610

File tree

2 files changed

+165
-127
lines changed

2 files changed

+165
-127
lines changed

src/content/learn/manipulating-the-dom-with-refs.md

Lines changed: 57 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -247,13 +247,13 @@ export default function CatFriends() {
247247
<nav>
248248
<button onClick={() => scrollToCat(catList[0])}>Neo</button>
249249
<button onClick={() => scrollToCat(catList[5])}>Millie</button>
250-
<button onClick={() => scrollToCat(catList[9])}>Bella</button>
250+
<button onClick={() => scrollToCat(catList[8])}>Bella</button>
251251
</nav>
252252
<div>
253253
<ul>
254-
{catList.map((cat) => (
254+
{catList.map((cat, index) => (
255255
<li
256-
key={cat}
256+
key={`${cat}?${index}`}
257257
ref={(node) => {
258258
const map = getMap();
259259
map.set(cat, node);
@@ -275,9 +275,14 @@ export default function CatFriends() {
275275
function setupCatList() {
276276
const catList = [];
277277
for (let i = 0; i < 10; i++) {
278-
catList.push("https://loremflickr.com/320/240/cat?lock=" + i);
278+
if (i < 5) {
279+
catList.push("https://placecats.com/neo/320/240");
280+
} else if (i < 8) {
281+
catList.push("https://placecats.com/millie/320/240");
282+
} else {
283+
catList.push("https://placecats.com/bella/320/240");
284+
}
279285
}
280-
281286
return catList;
282287
}
283288

@@ -876,12 +881,30 @@ export default function CatFriends() {
876881
);
877882
}
878883

879-
const catList = [];
880-
for (let i = 0; i < 10; i++) {
881-
catList.push({
884+
const catCount = 10;
885+
const catList = new Array(catCount);
886+
for (let i = 0; i < catCount; i++) {
887+
const bucket = Math.floor(Math.random() * catCount) % 2;
888+
let imageUrl = '';
889+
switch (bucket) {
890+
case 0: {
891+
imageUrl = "https://placecats.com/neo/250/200";
892+
break;
893+
}
894+
case 1: {
895+
imageUrl = "https://placecats.com/millie/250/200";
896+
break;
897+
}
898+
case 2:
899+
default: {
900+
imageUrl = "https://placecats.com/bella/250/200";
901+
break;
902+
}
903+
}
904+
catList[i] = {
882905
id: i,
883-
imageUrl: 'https://loremflickr.com/250/200/cat?lock=' + i
884-
});
906+
imageUrl,
907+
};
885908
}
886909

887910
```
@@ -961,7 +984,7 @@ export default function CatFriends() {
961984
behavior: 'smooth',
962985
block: 'nearest',
963986
inline: 'center'
964-
});
987+
});
965988
}}>
966989
Next
967990
</button>
@@ -993,12 +1016,30 @@ export default function CatFriends() {
9931016
);
9941017
}
9951018

996-
const catList = [];
997-
for (let i = 0; i < 10; i++) {
998-
catList.push({
1019+
const catCount = 10;
1020+
const catList = new Array(catCount);
1021+
for (let i = 0; i < catCount; i++) {
1022+
const bucket = Math.floor(Math.random() * catCount) % 2;
1023+
let imageUrl = '';
1024+
switch (bucket) {
1025+
case 0: {
1026+
imageUrl = "https://placecats.com/neo/250/200";
1027+
break;
1028+
}
1029+
case 1: {
1030+
imageUrl = "https://placecats.com/millie/250/200";
1031+
break;
1032+
}
1033+
case 2:
1034+
default: {
1035+
imageUrl = "https://placecats.com/bella/250/200";
1036+
break;
1037+
}
1038+
}
1039+
catList[i] = {
9991040
id: i,
1000-
imageUrl: 'https://loremflickr.com/250/200/cat?lock=' + i
1001-
});
1041+
imageUrl,
1042+
};
10021043
}
10031044

10041045
```

0 commit comments

Comments
 (0)