Skip to content

Commit

Permalink
fix: fixed auto select book
Browse files Browse the repository at this point in the history
  • Loading branch information
Rizki36 committed May 2, 2022
1 parent 605185e commit 3575636
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/components/BooksPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import { useEffect } from 'react';
import { AnimatePresence, motion } from 'framer-motion';
import { useRouter } from 'next/router';

import { setActiveTab, setSearch } from '@/configs/redux/bookSlice';
import {
setActiveTab,
setSearch,
setSelectedBook,
} from '@/configs/redux/bookSlice';
import { useAppDispatch, useAppSelector } from '@/configs/redux/hooks';

import Container from '../Container';
Expand All @@ -24,6 +28,9 @@ const BooksPage = () => {

if (search) dispatch(setSearch(search));
if (section === 'favorite') dispatch(setActiveTab('favorite'));

// unselect book when first load
dispatch(setSelectedBook(null));
}, [dispatch, router.query]);

const { activeTab } = useAppSelector((state) => state.book);
Expand Down

0 comments on commit 3575636

Please sign in to comment.