Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(nativeFilters): Speed up native filters by removing unnecessary rerenders #25282

Merged
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export enum AppSection {
export type FilterState = { value?: any; [key: string]: any };

export type DataMask = {
__cache?: FilterState;
extraFormData?: ExtraFormData;
filterState?: FilterState;
ownState?: JsonObject;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,12 @@ const VerticalFilterBar: React.FC<VerticalBarProps> = ({
/>
</FilterControlsWrapper>
),
[canEdit, dataMaskSelected, filterValues.length, onSelectionChange],
[
canEdit,
JSON.stringify(dataMaskSelected),
Always-prog marked this conversation as resolved.
Show resolved Hide resolved
filterValues.length,
onSelectionChange,
],
);

const filterSetsTabs = useMemo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ const FilterBar: React.FC<FiltersBarProps> = ({
verticalConfig,
hidden = false,
}) => {
console.log('rerender');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops

Suggested change
console.log('rerender');
console.log('rerender');

const history = useHistory();
const dataMaskApplied: DataMaskStateWithId = useNativeFiltersDataMask();
const [dataMaskSelected, setDataMaskSelected] =
Expand Down Expand Up @@ -166,7 +167,7 @@ const FilterBar: React.FC<FiltersBarProps> = ({
};
});
},
[dataMaskSelected, dispatch, setDataMaskSelected],
[JSON.stringify(dataMaskSelected), dispatch, setDataMaskSelected],
Always-prog marked this conversation as resolved.
Show resolved Hide resolved
);

useEffect(() => {
Expand Down
1 change: 1 addition & 0 deletions superset-frontend/src/dataMask/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export function getInitialDataMask(
}
return {
...otherProps,
__cache: {},
extraFormData: {},
filterState: {},
ownState: {},
Expand Down
Loading