Skip to content
This repository has been archived by the owner on Aug 7, 2024. It is now read-only.

Commit

Permalink
fix: removed unnecessary useState (#6580)
Browse files Browse the repository at this point in the history
* Removed unnecessary useState

* Update search.js

Removed `_` as per my conversation with **Sir Eddie Jaoude**.
  • Loading branch information
omlondhe authored May 7, 2023
1 parent 21f432b commit 71187d4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 16 deletions.
17 changes: 8 additions & 9 deletions components/navbar/Navbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,19 @@ const FaRegMoon = getIcon("FaRegMoon");
const FaSun = getIcon("FaSun");

export default function Navbar() {
const { systemTheme, theme, setTheme } = useTheme();
const [isOpen, setIsOpen] = useState(false);
const [mounted, setMounted] = useState(false);

const router = useRouter();
const navConRef = useRef();
const { data: session } = useSession();
const { systemTheme, theme, setTheme } = useTheme();
const getLink = (path) => `${router.basePath}${path}`;

useEffect(() => {
setMounted(true);
}, []);

const { data: session } = useSession();
const [isOpen, setIsOpen] = useState(false);

const router = useRouter();
const getLink = (path) => `${router.basePath}${path}`;
const navConRef = useRef();

const renderThemeChanger = () => {
if (!mounted) {
return null;
Expand All @@ -38,7 +37,7 @@ export default function Navbar() {
if (currentTheme === "dark") {
return (
<button
className="p-2"
className="p-2"
onClick={() => setTheme("light")}
aria-label="Toggle Theme"
>
Expand Down
8 changes: 3 additions & 5 deletions pages/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default function Events({ events }) {
event.date.cfpClose ? new Date(event.date.cfpClose) > new Date() : false
),
};
const filters = [
const tabFilters = [
{
title: "Show all",
description: "List all events with no filters",
Expand Down Expand Up @@ -84,7 +84,6 @@ export default function Events({ events }) {
},
];

const [tabs, setTabs] = useState(filters);
const [eventType, setEventType] = useState("all");

return (
Expand All @@ -106,15 +105,14 @@ export default function Events({ events }) {
</Badge>
</div>
<EventTabs
tabs={tabs}
tabs={tabFilters}
eventType={eventType}
setEventType={setEventType}
/>
<h2 className="text-md md:text-2xl text-lg text-primary-high font-bold md:mb-6 mb-3">
{filters.find((filter) => filter.key === eventType).description}
{tabFilters.find((filter) => filter.key === eventType).description}
</h2>
<ul role="list" className="divide-y divide-primary-low mt-6">

{categorisedEvents[eventType]?.map((event) => (
<EventCard
event={event}
Expand Down
4 changes: 2 additions & 2 deletions pages/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Badge from "@components/Badge";
import logger from "@config/logger";
import Input from "@components/form/Input";

export async function getServerSideProps(context) {
export async function getServerSideProps() {
let data = {
users: [],
tags: [],
Expand Down Expand Up @@ -40,8 +40,8 @@ export default function Search({ data }) {
let { users, tags } = data;
const router = useRouter();
const { username, keyword } = router.query;
const [filteredUsers, setFilteredUsers] = useState([]);
const [notFound, setNotFound] = useState();
const [filteredUsers, setFilteredUsers] = useState([]);
const [inputValue, setInputValue] = useState(username || keyword || "");

let results = [];
Expand Down

0 comments on commit 71187d4

Please sign in to comment.