Skip to content

Commit 65e3168

Browse files
authored
fix: rerende slider chidldren on their update (#380)
1 parent 423c48d commit 65e3168

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/blocks/Slider/Slider.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, {useCallback, useContext, useEffect, useRef, useState} from 'react';
1+
import React, {useCallback, useContext, useEffect, useMemo, useRef, useState} from 'react';
22

33
import _ from 'lodash';
44
import SlickSlider, {Settings} from 'react-slick';
@@ -78,8 +78,9 @@ export const SliderBlock = (props: WithChildren<SliderProps>) => {
7878
const {isServer} = useContext(SSRContext);
7979
const isMobile = useContext(MobileContext);
8080
const [breakpoint, setBreakpoint] = useState<number>(BREAKPOINTS.xl);
81-
const [disclosedChildren] = useState<React.ReactElement[]>(() =>
82-
discloseAllNestedChildren(children as React.ReactElement[]),
81+
const disclosedChildren = useMemo<React.ReactElement[]>(
82+
() => discloseAllNestedChildren(children as React.ReactElement[]),
83+
[children],
8384
);
8485
const childrenCount = disclosedChildren.length;
8586

0 commit comments

Comments
 (0)