Skip to content

Commit

Permalink
Merge pull request #28 from Rizki36/#27-unselect-book-when-leave-from…
Browse files Browse the repository at this point in the history
…-details-book-page

#27 unselect book when leave from details book page
  • Loading branch information
Rizki36 committed May 2, 2022
2 parents 605185e + 3575636 commit ee2d64e
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

1 comment on commit ee2d64e

@vercel
Copy link

@vercel vercel bot commented on ee2d64e May 2, 2022

Choose a reason for hiding this comment

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

Please sign in to comment.