react-utils - v1.0.31
    Preparing search index...

    Function getInitialWidth

    • Custom hook to track and respond to viewport breakpoint changes. Provides responsive design information based on window width.

      Returns number

      An object containing:

      • isMobile: boolean (width < 768px)
      • isTablet: boolean (768px <= width < 1024px)
      • isDesktop: boolean (width >= 1024px)
      • current: Breakpoint type ('mobile' | 'tablet' | 'desktop')
      // Basic usage
      const { isMobile, current } = useBreakpoint();
      if (isMobile) {
      // Render mobile component
      }
      // Conditional rendering
      const { current } = useBreakpoint();
      return (
      <div>
      {current === 'mobile' ? <MobileView /> : <DesktopView />}
      </div>
      );
      • BreakpointResult for return type structure
      • Breakpoint for available breakpoint values