Skip to content

Commit 5f8fd33

Browse files
committed
Fix bug with checkbox list causing infinite re-renders when panel toggled
1 parent 193d94a commit 5f8fd33

File tree

3 files changed

+4
-16
lines changed

3 files changed

+4
-16
lines changed

strudel-taskflows/src/components/CheckboxList.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ export const CheckboxList: React.FC<CheckboxListProps> = ({
3939
};
4040

4141
useEffect(() => {
42-
console.log(checkValues)
43-
if (onChange) onChange(checkValues);
42+
if (onChange && checkValues?.length !== values?.length) {
43+
onChange(checkValues);
44+
}
4445
}, [checkValues]);
4546

4647
useEffect(() => {

strudel-taskflows/src/components/FilterContext.tsx

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,10 @@ function filterReducer(state: FilterState, action: FilterAction): FilterState {
4343
} else if (filter.value) {
4444
activeFilters.push(filter);
4545
}
46-
console.log(activeFilters);
4746
return {
4847
...state,
4948
activeFilters
5049
}
51-
// return {
52-
// ...state,
53-
// activeFilters: { ...state.activeFilters, [action.payload.field]: action.payload.value }
54-
// }
5550
}
5651
case 'SET_ACTIVE_FILTERS': {
5752
return {
@@ -95,14 +90,6 @@ export const FilterContext: React.FC<FilterContextProps> = ({
9590
if (onChange) onChange(state.activeFilters);
9691
}, [JSON.stringify(state.activeFilters)]);
9792

98-
/**
99-
* If activeFilters is changed from outside the context (e.g. filters are reset)
100-
* then the new value should be dispatched.
101-
*/
102-
// useEffect(() => {
103-
// dispatch({ type: 'SET_ACTIVE_FILTERS', payload: activeFilters });
104-
// }, [activeFilters]);
105-
10693
return (
10794
<FilterContextAPI.Provider value={value}>
10895
{children}

strudel-taskflows/src/pages/explore-data/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Box, Grid, Paper, Stack } from '@mui/material';
1+
import { Box, Paper, Stack } from '@mui/material';
22
import React, { useState } from 'react';
33
import { FilterContext } from '../../components/FilterContext';
44
import { PageHeader } from '../../components/PageHeader';

0 commit comments

Comments
 (0)