@@ -90,7 +90,13 @@ const calculateHeight = (sideContentHeight?: number) => {
9090
9191type Props = OwnProps & StateProps & DispatchProps ;
9292
93- const SideContentCseMachineBase : React . FC < Props > = props => {
93+ const SideContentCseMachineBase : React . FC < Props > = ( {
94+ handleStepUpdate,
95+ handleEditorEval,
96+ setEditorHighlightedLines,
97+ handleAlertSideContent,
98+ ...props
99+ } ) => {
94100 const [ visualization , setVisualization ] = useState < React . ReactNode > ( null ) ;
95101 const [ value , setValue ] = useState ( - 1 ) ;
96102 const [ width , setWidth ] = useState ( calculateWidth ( props . editorWidth ) ) ;
@@ -100,16 +106,17 @@ const SideContentCseMachineBase: React.FC<Props> = props => {
100106
101107 const isJava = useCallback ( ( ) => props . chapter === Chapter . FULL_JAVA , [ props . chapter ] ) ;
102108
103- const handleResize = useCallback (
104- debounce ( ( ) => {
105- const newWidth = calculateWidth ( props . editorWidth ) ;
106- const newHeight = calculateHeight ( props . sideContentHeight ) ;
107- if ( newWidth !== width || newHeight !== height ) {
108- setWidth ( newWidth ) ;
109- setHeight ( newHeight ) ;
110- CseMachine . updateDimensions ( newWidth , newHeight ) ;
111- }
112- } , 300 ) ,
109+ const handleResize = useMemo (
110+ ( ) =>
111+ debounce ( ( ) => {
112+ const newWidth = calculateWidth ( props . editorWidth ) ;
113+ const newHeight = calculateHeight ( props . sideContentHeight ) ;
114+ if ( newWidth !== width || newHeight !== height ) {
115+ setWidth ( newWidth ) ;
116+ setHeight ( newHeight ) ;
117+ CseMachine . updateDimensions ( newWidth , newHeight ) ;
118+ }
119+ } , 300 ) ,
113120 [ props . editorWidth , props . sideContentHeight , width , height ]
114121 ) ;
115122
@@ -127,24 +134,24 @@ const SideContentCseMachineBase: React.FC<Props> = props => {
127134 useEffect ( ( ) => {
128135 if ( isJava ( ) ) {
129136 JavaCseMachine . init ( setVisualization , ( segments : [ number , number ] [ ] ) => {
130- props . setEditorHighlightedLines ( 0 , segments ) ;
137+ setEditorHighlightedLines ( 0 , segments ) ;
131138 } ) ;
132139 } else {
133140 CseMachine . init (
134141 visualization => {
135142 setVisualization ( visualization ) ;
136143 CseAnimation . playAnimation ( ) ;
137- if ( visualization ) props . handleAlertSideContent ( ) ;
144+ if ( visualization ) handleAlertSideContent ( ) ;
138145 } ,
139146 width ,
140147 height ,
141148 ( segments : [ number , number ] [ ] ) => {
142- props . setEditorHighlightedLines ( 0 , segments ) ;
149+ setEditorHighlightedLines ( 0 , segments ) ;
143150 } ,
144151 ( ) => setStepLimitExceeded ( false )
145152 ) ;
146153 }
147- } , [ isJava , props , width , height ] ) ;
154+ } , [ isJava , handleAlertSideContent , width , height , setEditorHighlightedLines ] ) ;
148155
149156 useEffect ( ( ) => {
150157 if ( props . needCseUpdate ) {
@@ -160,17 +167,17 @@ const SideContentCseMachineBase: React.FC<Props> = props => {
160167 const sliderRelease = useCallback (
161168 ( newValue : number ) => {
162169 setLastStep ( newValue === props . stepsTotal ) ;
163- props . handleEditorEval ( ) ;
170+ handleEditorEval ( ) ;
164171 } ,
165- [ props ]
172+ [ handleEditorEval , props . stepsTotal ]
166173 ) ;
167174
168175 const sliderShift = useCallback (
169176 ( newValue : number ) => {
170- props . handleStepUpdate ( newValue ) ;
177+ handleStepUpdate ( newValue ) ;
171178 setValue ( newValue ) ;
172179 } ,
173- [ props ]
180+ [ handleStepUpdate ]
174181 ) ;
175182
176183 const stepPrevious = useCallback ( ( ) => {
0 commit comments