useMemo on composed style

This commit is contained in:
Xevion
2022-11-26 12:34:41 -06:00
parent 06bffb8907
commit dc573fd1b7

View File

@@ -7,6 +7,7 @@ import {
EyeIcon, EyeIcon,
EyeSlashIcon, EyeSlashIcon,
} from "@heroicons/react/24/solid"; } from "@heroicons/react/24/solid";
import { useMemo } from "react";
function App() { function App() {
const { width, height } = useWindowSize(); const { width, height } = useWindowSize();
@@ -25,9 +26,11 @@ function App() {
iconSpinning ? 200 : null iconSpinning ? 200 : null
); );
const style = { const style = useMemo(() => {
background: [`url("${svg}")`, ...backgrounds].join(", "), return {
}; background: [`url("${svg}")`, ...backgrounds].join(", "),
};
}, [svg, backgrounds]);
return ( return (
<div <div
@@ -61,6 +64,7 @@ function App() {
className={`h-[100vh] transition-opacity ease-in-out duration-75 ${ className={`h-[100vh] transition-opacity ease-in-out duration-75 ${
postHidden ? "opacity-0" : "" postHidden ? "opacity-0" : ""
} flex col-span-9 sm:col-span-6 md:col-span-5 w-full min-h-[100vh]`} } flex col-span-9 sm:col-span-6 md:col-span-5 w-full min-h-[100vh]`}
> >
<div className="bg-white overflow-y-auto"> <div className="bg-white overflow-y-auto">
<Post /> <Post />