mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-01-23 05:24:55 +03:00
refactor: add non re-render rules to useEffect
This commit is contained in:
parent
548b7c3f41
commit
cd871ec359
@ -14,10 +14,12 @@ export function SidebarSection({ title, children }: SidebarSectionProps) {
|
||||
const [height, setHeight] = useState(0);
|
||||
|
||||
useEffect(() => {
|
||||
if (content.current) {
|
||||
if (content.current && content.current.scrollHeight !== height) {
|
||||
setHeight(isOpen ? content.current.scrollHeight : 0);
|
||||
} else if (!isOpen) {
|
||||
setHeight(0);
|
||||
}
|
||||
}, [isOpen, children]);
|
||||
}, [isOpen, children, height]);
|
||||
|
||||
return (
|
||||
<div>
|
||||
|
Loading…
Reference in New Issue
Block a user