@@ -93,21 +93,13 @@ const Reviews = () => {
9393 const [ slidesToShowState , setSlidesToShowState ] = useState ( null ) ;
9494 const sliderRef = useRef ( null ) ;
9595
96- /* Merge runtime slidesToShow into settings and disable internal responsive handling.
97- We disable the internal `responsive` array here because we compute the
98- desired `slidesToShow` at runtime (based on window width) and pass it
99- directly to the slider to avoid conflicting calculations and race
100- conditions that can occur during initial mount. */
10196 const mergedSettings = {
10297 ...settings ,
10398 slidesToShow : slidesToShowState || 1 ,
10499 slidesToScroll : 1 ,
105100 responsive : [ ]
106101 } ;
107102
108- /* computeSlides: determine the appropriate slidesToShow based on the
109- current window width. This centralises the breakpoint logic so we can
110- compute the initial value synchronously and reuse it in resize handlers. */
111103 const computeSlides = ( ) => {
112104 const w = typeof window !== "undefined" ? ( window . innerWidth || document . documentElement . clientWidth ) : 1200 ;
113105 if ( w <= 800 ) return 1 ;
@@ -116,19 +108,7 @@ const Reviews = () => {
116108 } ;
117109
118110 useLayoutEffect ( ( ) => {
119- /* Initialise slider state synchronously before paint to avoid a flash of
120- incorrect layout. We set slidesToShowState here so the Slider mounts with
121- the right number of slides on initial render.
122111
123- onResizeDebounced: debounced handler that recomputes slides and asks
124- the react-slick instance to remeasure (via onWindowResized). Debounce
125- helps avoid rapid repeated calls during a resize gesture.
126-
127- onLoad: we also listen for the window "load" event and each slide image
128- "load" event because images can change the layout width; when an image
129- finishes loading we rerun the debounced handler to ensure the slider
130- recalculates correctly.
131- */
132112 setIsClient ( true ) ;
133113 setSlidesToShowState ( computeSlides ( ) ) ;
134114
@@ -168,7 +148,6 @@ const Reviews = () => {
168148 < ReviewsWrapper >
169149 < div className = "slider" >
170150 < h2 > Hear what other users have to say...</ h2 >
171- { /* key property will force React to remount the Slider when slidesToShowState changes. */ }
172151 < Slider key = { `review-slider-${ slidesToShowState } ` } ref = { sliderRef } { ...mergedSettings } >
173152 { /* <Customers
174153 type="1"
0 commit comments