Skip to content

🎥 Make videos programmatically with React

it's okay to use randomness inside calculateMetadata()

Jonny Burger4ab89d64458c
diff --git a/packages/docs/docs/using-randomness.md b/packages/docs/docs/using-randomness.md
index 812cf6b4f8..575d207a4c 100644
--- a/packages/docs/docs/using-randomness.md
+++ b/packages/docs/docs/using-randomness.md
@@ -17,7 +17,7 @@ const MyComp: React.FC = () => {
x: Math.random(),
y: Math.random(),
};
- })
+ }),
);
// Do something with coordinates
return <></>;
@@ -51,6 +51,10 @@ Now the random values will be the same on all threads.
Did you get an ESLint warning when using `Math.random()`, but you are fully aware of the circumstances described above? Use `random(null)` to get a true random value without getting a warning.
+## Exception: Inside `calculateMetadata()`
+
+It is safe to use true random values inside [`calculateMetadata()`](/docs/calculate-metadata), as it is only called once and not in parallel.
+
## See also
- [random()](/docs/random)