File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed
src/components/visualizers Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import { VisualizerProps } from '../../interfaces';
6
6
7
7
export const MergeSortVisualizer : React . FC < VisualizerProps > = ( {
8
8
array,
9
+ arraySize,
9
10
setArray,
10
11
setIsSorting,
11
12
sortRef,
@@ -16,8 +17,8 @@ export const MergeSortVisualizer: React.FC<VisualizerProps> = ({
16
17
const tl = gsap . timeline ( ) ; // todo: find better way than using global gsap timeline element
17
18
18
19
useEffect ( ( ) => {
19
- sortRef . current = ( ) => startSort ( ) ;
20
- } , [ sortRef ] ) ;
20
+ sortRef . current = ( array : number [ ] ) => startSort ( array ) ;
21
+ } , [ sortRef , array , arraySize ] ) ;
21
22
22
23
const mergeSort = async ( array : number [ ] , left = 0 ) : Promise < number [ ] > => {
23
24
if ( array . length <= 1 ) {
@@ -118,7 +119,7 @@ export const MergeSortVisualizer: React.FC<VisualizerProps> = ({
118
119
} ,
119
120
) ;
120
121
121
- const startSort = async ( ) => {
122
+ const startSort = async ( array : number [ ] ) => {
122
123
setIsSorting ( true ) ;
123
124
const sortedArray = await mergeSort ( [ ...array ] ) ;
124
125
setArray ( sortedArray ) ;
You can’t perform that action at this time.
0 commit comments