function useLocalStorage(key, initial, hydrateWithInitial) {
	const [v, setValue] = useState(() => {
		const stored = hydrateWithInitial ? null : getItem(key);
		return stored == null ? initial : stored;
	});
	
	useLayoutEffect(() => {
		if (hydrateWithInitial) {
			const stored = getItem(key);
			if (stored != null) setValue(stored);
		}
	}, []);

	const set = v => {
		if (SUPPORTS_LOCAL_STORAGE) {
			localStorage.setItem(key, v);
		}
		setValue(v);
	};

	return [v, set];
}
@type {<T>(name: string, value: T, hydrateWithInitial: boolean) => [T, (v: T) => void]}