File tree Expand file tree Collapse file tree 3 files changed +16
-9
lines changed Expand file tree Collapse file tree 3 files changed +16
-9
lines changed Original file line number Diff line number Diff line change @@ -50,7 +50,7 @@ const Cart = ({ stickyNav }: ICartProps) => {
5050
5151 { productCount && (
5252 < span
53- className = { `w-6 h-6 pb-2 -mt-5 text-center rounded-full
53+ className = { `w-6 h-6 pb-2 -mt-5 !ml-auto text-center rounded-full
5454 ${ stickyNav ? 'text-black bg-white' : 'text-white bg-black' } ` }
5555 >
5656 { productCount }
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ interface IHeaderProps {
1616const Header = ( { title } : IHeaderProps ) => (
1717 < >
1818 < Head >
19- < title > Next.js webshop with WooCommerce { title } </ title >
19+ < title > { ` Next.js webshop with WooCommerce $ {title } ` } </ title >
2020 < meta name = "description" content = "WooCommerce webshop" />
2121 < meta name = "keywords" content = "Ecommerce, WooCommerce" />
2222 < meta
Original file line number Diff line number Diff line change 1- import { useLayoutEffect , useState } from 'react' ;
1+ import { useEffect , useState } from 'react' ;
22import debounce from 'lodash/debounce' ;
33
44const useIsMobile = ( ) : boolean => {
5- const [ isMobile , setIsMobile ] = useState ( false ) ;
5+ // Initialize with null to avoid hydration mismatch
6+ const [ isMobile , setIsMobile ] = useState < boolean | null > ( null ) ;
67
7- useLayoutEffect ( ( ) => {
8- const updateSize = ( ) : void => {
8+ useEffect ( ( ) => {
9+ // Skip effect on server side
10+ if ( typeof window === 'undefined' ) return ;
11+
12+ const updateSize = debounce ( ( ) : void => {
913 setIsMobile ( window . innerWidth < 768 ) ;
10- } ;
11- window . addEventListener ( 'resize' , debounce ( updateSize , 250 ) ) ;
14+ } , 250 ) ;
15+
16+ // Initial check
1217 updateSize ( ) ;
1318
19+ window . addEventListener ( 'resize' , updateSize ) ;
1420 return ( ) : void => window . removeEventListener ( 'resize' , updateSize ) ;
1521 } , [ ] ) ;
1622
17- return isMobile ;
23+ // Return false during SSR, actual value after hydration
24+ return isMobile ?? false ;
1825} ;
1926
2027export default useIsMobile ;
You can’t perform that action at this time.
0 commit comments