mirror of
https://github.com/Xevion/grain.git
synced 2025-12-06 21:15:15 -06:00
Add memoization to useBackground
This commit is contained in:
@@ -47,9 +47,10 @@ const useBackground = ({
|
|||||||
setBackground(generateBackground());
|
setBackground(generateBackground());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const noise = useMemo(() => {
|
||||||
const svgWidth = Math.ceil((width ?? 1920) * ratio);
|
const svgWidth = Math.ceil((width ?? 1920) * ratio);
|
||||||
const svgHeight = Math.ceil((height ?? 1080) * ratio);
|
const svgHeight = Math.ceil((height ?? 1080) * ratio);
|
||||||
const noise = (
|
return (
|
||||||
<svg
|
<svg
|
||||||
viewBox={`0 0 ${svgWidth} ${svgHeight}`}
|
viewBox={`0 0 ${svgWidth} ${svgHeight}`}
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
@@ -68,6 +69,7 @@ const useBackground = ({
|
|||||||
</g>
|
</g>
|
||||||
</svg>
|
</svg>
|
||||||
);
|
);
|
||||||
|
}, [width, height, ratio]);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
regenerate,
|
regenerate,
|
||||||
|
|||||||
Reference in New Issue
Block a user