Skip to content

Commit

Permalink
modified header onClick event
Browse files Browse the repository at this point in the history
  • Loading branch information
AmirKakavand committed Aug 9, 2024
1 parent c0cb526 commit f5fe2cb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 3 additions & 1 deletion app/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@ import { IoIosSearch } from "react-icons/io";

interface IHeaderProps {
name: string;
setPageNo: Dispatch<SetStateAction<number>>;
setName: Dispatch<SetStateAction<string>>;
setSearchQuery: Dispatch<SetStateAction<string>>;
}

const Header = ({ name, setName, setSearchQuery }: IHeaderProps) => {
const Header = ({ name, setPageNo, setName, setSearchQuery }: IHeaderProps) => {
const [mouseHover, setMouseHover] = useState<boolean>(false);
return (
<header className="flex flex-col md:flex-row justify-around">
<button onClick={() => {
setSearchQuery("")
setName("")
setPageNo(1)
}}>
<h1 className={h1Class}>
Rick and Morty Wiki
Expand Down
7 changes: 6 additions & 1 deletion app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ export default function Home() {
useEffect(() => handleSearch({ name, setSearchQuery, setPageNo }), [name]);
return (
<main className={mainClass}>
<Header name={name} setName={setName} setSearchQuery={setSearchQuery} />
<Header
name={name}
setPageNo={setPageNo}
setName={setName}
setSearchQuery={setSearchQuery}
/>
{searchQuery === "" && (
<CharactersPage pageNo={pageNo} setPageNo={setPageNo} />
)}
Expand Down

0 comments on commit f5fe2cb

Please sign in to comment.