mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-05 16:04:43 +00:00
Measure the header row width and hide text labels on the Open, Scripts, and git action split buttons below 700px so the header fits without wrapping on split-pane layouts.
19 lines
444 B
TypeScript
19 lines
444 B
TypeScript
import { useCallback, useState } from "react";
|
|
import type { LayoutChangeEvent } from "react-native";
|
|
|
|
/**
|
|
* Tracks the width of a container via onLayout.
|
|
*/
|
|
export function useContainerWidth(): {
|
|
onLayout: (e: LayoutChangeEvent) => void;
|
|
width: number;
|
|
} {
|
|
const [width, setWidth] = useState(0);
|
|
return {
|
|
onLayout: useCallback((e: LayoutChangeEvent) => {
|
|
setWidth(e.nativeEvent.layout.width);
|
|
}, []),
|
|
width,
|
|
};
|
|
}
|