Skip to content

Commit

Permalink
feat: reset the filter on route changed
Browse files Browse the repository at this point in the history
  • Loading branch information
ReidyT committed Feb 9, 2024
1 parent d41dd05 commit 68f50e3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/components/context/FilterItemsContext.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { createContext, useContext, useMemo, useState } from 'react';
import { createContext, useContext, useEffect, useMemo, useState } from 'react';
import { useLocation } from 'react-router';

import { DiscriminatedItem } from '@graasp/sdk';

Expand Down Expand Up @@ -35,8 +36,11 @@ type Props = {
export const FilterItemsContextProvider = ({
children,
}: Props): JSX.Element => {
const location = useLocation();
const [itemTypes, setItemTypes] = useState<ItemTypes>([]);

useEffect(() => setItemTypes([]), [location]);

const value = useMemo(
() => ({
itemTypes,
Expand Down

0 comments on commit 68f50e3

Please sign in to comment.