I asked a question here about how to get 20 random items from that JSON and I used one of the answers like this:
const a = Myjson;
useEffect(() => {
for (let i = a.length; i-- > 0; ) {
const j = Math.floor(Math.random() * i); // 0 ≤ j ≤ i
[a[i], a[j]] = [a[j], a[i]];
}
}, []);
{a
.slice(0, 20)
.map((item) => (
<Link
href={item.ud}
key={item.id}
>
{item.test}
</Link>
))}
There is a problem that when I refresh I see the ordered 20 items of that JSON and then suddenly it changes to random 20 items; how can I fix the code so when I refresh I can only see the random 20 items without seeing those ordered items?