Skip to content

Commit

Permalink
refetch tasks on user login/logout #69 #71
Browse files Browse the repository at this point in the history
- import the useCurrentUser hook:
zimport { useCurrentUser } from "../../contexts/CurrentUserContext";z
- call it within the `TaskList` component:
`const currentUser = useCurrentUser();`
- add it to the `useEffect` hook’s dependency array:
`}, [filter, query, pathname, currentUser]);`
  • Loading branch information
blahosyl committed Aug 6, 2024
1 parent 0e27498 commit d1673ef
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/pages/tasks/TaskList.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import Task from "./Task";
import Asset from "../../components/Asset";
import NoResults from "../../assets/no-results.png";
import ProfileList from "../profiles/ProfileList";
import { useCurrentUser } from "../../contexts/CurrentUserContext";

function TaskList({ message, filter = "" }) {
const [tasks, setTasks] = useState({ results: [] });
Expand All @@ -24,6 +25,8 @@ function TaskList({ message, filter = "" }) {

const [query, setQuery] = useState("");

const currentUser = useCurrentUser();

useEffect(() => {
const fetchTasks = async () => {
try {
Expand All @@ -43,7 +46,7 @@ function TaskList({ message, filter = "" }) {
return () => {
clearTimeout(timer);
};
}, [filter, query, pathname]);
}, [filter, query, pathname, currentUser]);

return (
<Row className="h-100">
Expand Down

0 comments on commit d1673ef

Please sign in to comment.