import { useEffect, useRef, useState } from 'react'; // One activation order for floating data windows and Results; Filters has its own uppermost layer. let nextLayer = 3000; // Reserve the next integer for the active Result inside a shared cluster. const allocateLayer = () => (nextLayer += 2); export function useFloatingWindowLayer(activation?: number) { const [layer, setLayer] = useState(allocateLayer); const previous = useRef(activation); const activate = () => setLayer(allocateLayer()); useEffect(() => { if (previous.current === activation) return; previous.current = activation; activate(); }, [activation]); return { layer, activate }; }